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

Support local as an environment for Rails/UnknownEnv from Rails 7.1 onward. #894

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

ghiculescu
Copy link
Contributor

@ghiculescu ghiculescu commented Dec 23, 2022

Fixes #893


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • 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.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

RuboCop::Config.new(
{
'AllCops' => {
'TargetRailsVersion' => '7.1'
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this PR and added support for local as part #906 as well. I think this approach is better, although it may make sense to cherry pick my commit introducing a :rails71 shared context (or I can open a separate PR for that, but it seems small) rather than a custom config, especially given the rest of this config is just the defaults.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've extracted the shared context into its own PR in #1134.

@@ -0,0 +1 @@
* [#893](https://github.com/rubocop/rubocop-rails/issues/893): Support `local` as an environment for `Rails/UnknownEnv` from Rails 7.1 onward. ([@ghiculescu][])
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this warrant updating the cop's VersionChanged config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably? I'm not very familiar with how this works. Do I add the next version number or is there some other workflow for this?

@ghiculescu
Copy link
Contributor Author

@koic do you have any opinions on this PR vs #906 ?

@koic
Copy link
Member

koic commented Mar 8, 2023

Rails 7.1 is a development version yet. So, the new feature for Rails 7.1 merge is pending until at least a beta, preferably a release candidate is shipped.
#906 (comment)

@ghiculescu
Copy link
Contributor Author

Got it. Thanks.

@mjankowski
Copy link
Contributor

Rails 7.1.0.beta1 is out, and this feature (adding local? method) is included.

@koic
Copy link
Member

koic commented Sep 20, 2023

The release of RC is probably not far away. In principle, API will be stable once it becomes RC, so let's wait for a while.

@mjankowski
Copy link
Contributor

The release of RC is probably not far away. In principle, API will be stable once it becomes RC, so let's wait for a while.

Makes sense!

Also: 7.1.0.rc1 is out now

@sambostock sambostock mentioned this pull request Sep 28, 2023
5 tasks
Comment on lines +87 to +105
context 'Rails 7.1' do
let(:config) do
RuboCop::Config.new(
{
'AllCops' => {
'TargetRailsVersion' => '7.1'
},
'Rails/UnknownEnv' => {
'Environments' => %w[
development
production
test
]
}
}
)
end

it 'accepts local as an environment name on Rails 7.1' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that #1134 has been merged, I think this could be changed to use the shared context and cop_config defined above. We also don't need to repeat "Rails 7.1" in the spec name, as it is already in the context name.

Suggested change
context 'Rails 7.1' do
let(:config) do
RuboCop::Config.new(
{
'AllCops' => {
'TargetRailsVersion' => '7.1'
},
'Rails/UnknownEnv' => {
'Environments' => %w[
development
production
test
]
}
}
)
end
it 'accepts local as an environment name on Rails 7.1' do
context 'in Rails 7.1 onwards', :rails71 do
it 'accepts local as an environment name' do

Copy link
Member

Choose a reason for hiding this comment

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

@ghiculescu ping.

@ghiculescu
Copy link
Contributor Author

Thanks for the PR. I'm not going to be able to work on this for a little while, @sambostock or @koic are you interested in taking it over? Happy to close this PR and move to a new one if you like.

@koic
Copy link
Member

koic commented Oct 6, 2023

Well, adjustments to the test code can be done separately. I'm going to merge this PR. Thank you @ghiculescu!

@koic koic merged commit e773322 into rubocop:master Oct 6, 2023
@ghiculescu ghiculescu deleted the rails-env-local branch October 6, 2023 02:34
koic added a commit that referenced this pull request Oct 16, 2023
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.

Rails/UnknownEnv support Rails.env.local? by default for Rails 7.1
4 participants