Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark Rails/ApplicationController and similar cops as unsafe autocorrect #223

Merged
merged 1 commit into from
Apr 1, 2020

Conversation

hoshinotsuyoshi
Copy link
Contributor

@hoshinotsuyoshi hoshinotsuyoshi commented Mar 28, 2020

We have a controller class which inherits ActionController::Base directly.
That controller is for health check endpoint.

class HealthCheckController < ActionController::Base
  # we want to skip some authentication logics...
  def index
    head :ok
  end
end
class ApplicationController < ActionController::Base
  # default some authentication logics...
end

In such case, automatically modifying the ActionController :: Base-> ApplicationController is not safe .


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@hoshinotsuyoshi hoshinotsuyoshi force-pushed the application-controller-unsafe branch 2 times, most recently from 6cc2ff3 to f6035f0 Compare March 28, 2020 09:34
@@ -57,21 +57,25 @@ Rails/ActiveSupportAliases:
Rails/ApplicationController:
Description: 'Check that controllers subclass ApplicationController.'
Enabled: true
SafeAutoCorrect: false
VersionAdded: '2.4'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you mark VersionChanged: '2.5'?

Suggested change
VersionAdded: '2.4'
VersionAdded: '2.4'
VersionChanged: '2.5'

Same for other changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, updated && rebased && force-pushed a1aa7d5

…rect

We have a controller class which inherits `ActionController::Base` directly.
That controller is for health check endpoint.

```ruby
class HealthCheckController < ActionController::Base
  # we want to skip some authentication logics...
  def index
    head :ok
  end
end
```

```ruby
class ApplicationController < ActionController::Base
  # default some authentication logics...
end
```

In such case, automatically modifying the `ActionController :: Base`->` ApplicationController` is not safe .
@koic
Copy link
Member

koic commented Apr 1, 2020

This change looks good to me. Thanks for showing the use case for unsafe auto-correction.

@koic koic merged commit 32791a6 into rubocop:master Apr 1, 2020
@hoshinotsuyoshi hoshinotsuyoshi deleted the application-controller-unsafe branch April 1, 2020 03:14
@hoshinotsuyoshi
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants