Ruby Linting: Class vs. Lexical Scope

I’m in the process of implementing just about every possible linter for new projects. I’m going to use this topic to discuss some of the linting rules that may have puzzled me.

app/controllers/users/omniauth_callbacks_controller.rb:1:7: C: Use nested module/class definitions instead of compact style.
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

I’ve never paid much attention to this topic, and I have seen some odd issues surrounding classes not being found.

The default is “nested”. However, I’m thinking that “compact” is just fine per the description in the docs:

http://www.rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Style/ClassAndModuleChildren

I’m still not convinced that there’s anything wrong with preferring compact when there’s only one child of the module. But I’d like to understand if there’s a good reason.

Here’s a detailed discussion of the feature:

Here are some good questions and answers: