-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Enabling rubo configs/12 20 23 #241
base: main
Are you sure you want to change the base?
Enabling rubo configs/12 20 23 #241
Conversation
Hey! Thanks for wanting to help out! I'll have to let Luke do the actual review. But for your pull request title and description please follow the guidance from https://cbea.ms/git-commit It helps everyone to quickly see what your pull request is about. |
ruby/spec/cucumber/ci_environment/remove_user_info_from_url_spec.rb
Outdated
Show resolved
Hide resolved
(And yeah, awesome that you made a PR!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things to unpick or tweak if you can. Will chat on slack too.
ruby/spec/cucumber/ci_environment/detect_ci_environment_spec.rb
Outdated
Show resolved
Hide resolved
result = evaluate(expression, { 'GO_SCM_MY_MATERIAL_PR_BRANCH' => 'ashwankthkumar:feature-1' }) | ||
expect(result).to eq('feature-1') | ||
end | ||
|
||
it 'evaluates a complex expression' do | ||
expression = "hello-${VAR1}-${VAR2/(.*) (.*)/\\2-\\1}-world" | ||
expression = 'hello-${VAR1}-${VAR2/(.*) (.*)/\\2-\\1}-world' | ||
result = evaluate(expression, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're comfortable using multi-line here this can be fixed. Or I can tackle it at a later date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure what is meant by "multi-line" here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stylistically is quite wild now, so ideally it should be on multiple lines. i.e.
(
{
}
)
If you're not comfortable tidying it up, don't feel the need to fix it all. We can revisit these at a later date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm not understanding how the highlighted line could be refactored into multi line. The rest of that block is multi line. Do you mean the other blocks in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written above, the rubocop parser is detecting you want to have this right-aligned, which shifts all the code along. If you make it left aligned in the braces then it fixes this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Popped an update on to help you along if you have time.
variable = $1 | ||
pattern = $2 | ||
replacement = $3 | ||
variable = ::Regexp.last_match(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure these need to be top-level namespaced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass when refactoring ::Regexp
to just Regexp
do you want me to change these to Regexp
?
@@ -3,15 +3,15 @@ | |||
require 'cucumber/ci_environment' | |||
require 'json' | |||
|
|||
describe 'detect_ci_environment' do | |||
describe Cucumber::CiEnvironment, '.detect_ci_environment' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be in 2 blocks. So the top level should say
describe Cucumber::CiEnvironment
and then underneath it it should have the 2nd block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean refactor it to be ?
describe Cucumber::CiEnvironment do
it 'detects CI environment' do
<test code>
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2nd line should be describe '.detect_ci_environment'
ruby/spec/cucumber/ci_environment/detect_ci_environment_spec.rb
Outdated
Show resolved
Hide resolved
require 'cucumber/ci_environment' | ||
|
||
describe 'remove_user_info_from_url' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the above one.
require 'cucumber/ci_environment' | ||
|
||
describe 'Cucumber::CiEnvironment::VariableExpression.evaluate' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be in double blocks
require 'cucumber/ci_environment' | ||
|
||
describe 'Cucumber::CiEnvironment::VariableExpression.evaluate' do | ||
include Cucumber::CiEnvironment::VariableExpression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to amend this as this isn't the way to write these kinds of specs, we should be using isolated lets. But given this is already here we can ignore this and fix it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious as to how the let refactor would work and what is the difference? From looking at this spec file I can see what it is testing, the inputs and expected outputs are readily seen. What is bad about this rspec file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you include
something inside a describe block it pollutes the whole namespace. Dependent on how you ran / checked rubocop it will flag this to you. A better way it to use an isolated anonymous class inside a let so something like
let(:foo) do
Class.new(inheritance) do
include RequiredModule1
include RequiredModule2
end
end
Now the inclusion is completely isolated inside the memoized let.
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# TODO: Oct '23 -> 10 files inspected, 63 offenses detected, 53 offenses autocorrectable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you leave these stylistic markers in it'll show we're slowly getting more conformant. It'll also warn us if we're getting less conformant
result = evaluate(expression, { 'GO_SCM_MY_MATERIAL_PR_BRANCH' => 'ashwankthkumar:feature-1' }) | ||
expect(result).to eq('feature-1') | ||
end | ||
|
||
it 'evaluates a complex expression' do | ||
expression = "hello-${VAR1}-${VAR2/(.*) (.*)/\\2-\\1}-world" | ||
expression = 'hello-${VAR1}-${VAR2/(.*) (.*)/\\2-\\1}-world' | ||
result = evaluate(expression, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stylistically is quite wild now, so ideally it should be on multiple lines. i.e.
(
{
}
)
If you're not comfortable tidying it up, don't feel the need to fix it all. We can revisit these at a later date.
🤔 What's changed?
Regenerated rubcop todo and fixed warnings.
Added to rubocop config:
Metrics/AbcSize:
Max: 30
Metrics/MethodLength:
Max: 23
RSpec/ExampleLength:
Max: 6
⚡️ What's your motivation?
Helping out
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
I added some configs to rubocop.yml for code length. Should those be refactored to fit those cops instead?
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.