Skip to content

Fix Rubocop offences #2272

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

Merged
merged 83 commits into from
Mar 10, 2020
Merged

Fix Rubocop offences #2272

merged 83 commits into from
Mar 10, 2020

Conversation

babrovka
Copy link
Contributor

No description provided.

@babrovka babrovka changed the title Fix Style/ExpandPathArguments cop Fix Rubocop offences Jan 31, 2020
@babrovka babrovka force-pushed the fix-rubocop-offences branch 3 times, most recently from 90e1f0e to c73a76a Compare January 31, 2020 14:29
Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

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

👋 Thanks for taking the time to contribute this, in order for this to make sense as a PR the rubocop check within out build needs to be changed to apply to the entire project. Currently we only apply the rules to lib so if you'd like this merged it will need to be expanded to the whole project. Its in script/functions.sh

@babrovka babrovka force-pushed the fix-rubocop-offences branch 2 times, most recently from 65b3ddc to b0ab808 Compare February 3, 2020 10:43
@babrovka
Copy link
Contributor Author

babrovka commented Feb 3, 2020

👋 Thanks for taking the time to contribute this, in order for this to make sense as a PR the rubocop check within out build needs to be changed to apply to the entire project. Currently we only apply the rules to lib so if you'd like this merged it will need to be expanded to the whole project. Its in script/functions.sh

hey @JonRowe 👋 glad to help! I updated script/functions.sh so now Rubocop will check the whole project.

Please, don't merge it right now, I would like to go through all cops, one per commit.

@babrovka babrovka force-pushed the fix-rubocop-offences branch 2 times, most recently from fb6b07c to 668be98 Compare February 3, 2020 15:19
Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Oh wow, it took me a while to look though it.

Do you mind fixing a couple more things along the way?

I'm a bit concerned about disabling RedundantSelf, Colon, and weird new octal notation.

The rest of the comments are minor, I enjoy the new style, and would be happy to merge as-is.

Good job! 👏

Just an idea for a follow-up: we have some disabled cops in .rubocop_todo.yml, some of them are due to Ruby 1.8 legacy, and it should be quite easy to fix them.

@babrovka babrovka force-pushed the fix-rubocop-offences branch from a21a7e2 to 68c001f Compare February 17, 2020 14:19
@pirj pirj force-pushed the fix-rubocop-offences branch from 4cc0d69 to bbd1b38 Compare March 6, 2020 09:49
@pirj
Copy link
Member

pirj commented Mar 6, 2020

Updated from master and push-forced.

I can reproduce this locally:

spec/rspec/rails/example/feature_example_group_spec.rb:24:23: C: Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
          get "/foo", :as => :foo, :to => "foo#bar"
                      ^^^^^^

fixed ✅

Regarding:

        group = RSpec::Core::ExampleGroup.describe do
          include RequestExampleGroup
        end.describe do
          include FeatureExampleGroup
        end

and

spec/rspec/rails/example/feature_example_group_spec.rb:29:9: C: Style/MultilineBlockChain: Avoid multi-line chains of blocks.
        end.describe do
        ^^^^^^^^^^^^

wondering if this can be written as:

        group = RSpec::Core::ExampleGroup.describe do
          include RequestExampleGroup
          describe do
            include FeatureExampleGroup
          end
        end

will group be the outer group or the inner one?
Might be:

        outer_group = RSpec::Core::ExampleGroup.describe do
          include RequestExampleGroup
        end
        group = outer_group.describe do
          include FeatureExampleGroup
        end

@pirj
Copy link
Member

pirj commented Mar 6, 2020

Checked, group has the same ancestors as originally when the second approach is used.

@pirj
Copy link
Member

pirj commented Mar 6, 2020

Looks green 👍
@babrovka do you mind checking the remaining notes #2272 (review) ?

@pirj pirj requested a review from JonRowe March 6, 2020 11:11
@JonRowe
Copy link
Member

JonRowe commented Mar 10, 2020

I'm happy with this if it is done @babrovka? please let me handle the merge @pirj

@pirj
Copy link
Member

pirj commented Mar 10, 2020

Layout/SpaceInsideBlockBraces:
EnforcedStyleForEmptyBraces: space
19 offences

Layout/SpaceInsideBlockBraces:
EnforcedStyleForEmptyBraces: no_space (default)
51 offences

Reworked to use non-default space style for empty blocks.

@pirj
Copy link
Member

pirj commented Mar 10, 2020

Great job, @babrovka !

I'm ok with this, looks perfect. Good to squash-merge, @JonRowe?

Copy link
Member

@JonRowe JonRowe left a comment

Choose a reason for hiding this comment

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

Just one thing to change @pirj

@pirj pirj force-pushed the fix-rubocop-offences branch from 1b26d83 to cec3d2e Compare March 10, 2020 14:29
@pirj pirj requested a review from JonRowe March 10, 2020 14:33
@JonRowe JonRowe merged commit 9fb6c9c into rspec:master Mar 10, 2020
@JonRowe
Copy link
Member

JonRowe commented Mar 10, 2020

Thanks for your work here @babrovka and @pirj

JonRowe pushed a commit that referenced this pull request Mar 13, 2020
* Fix Style/ExpandPathArguments cop

* Layout/SpaceInsideBlockBraces

Offences count:
space: 51
no_space: 1395

* Style/PercentLiteralDelimiters

* Gemspec/OrderedDependencies

* Layout/ArgumentAlignment

Offences count:
with_first_argument: 13
with_fixed_indentation: 47

* Layout/BlockAlignment

Offences count:
either: 1
start_of_block: 4
start_of_line: 22

* Layout/ClosingHeredocIndentation

* Layout/DotPosition

Offences count:
leading: 34
trailing: 1

* Layout/EmptyLineAfterGuardClause

* Bundler/DuplicatedGem

* Layout/EmptyLines

* Layout/IndentationWidth

* Layout/SpaceAfterComma

* Layout/SpaceAroundEqualsInParameterDefault

Offenses count:
space: 3
no_space: 29

* Layout/SpaceBeforeBlockBraces

Offenses count:
space: 16
no_space: 52

* Layout/SpaceInsideHashLiteralBraces

Offenses count:
space: 73
no_space: 37
compact: 73

Set configuration for consistency:
`no_space` for non empty braces
`no_space` for empty braces

* Layout/SpaceInsideParens

Offenses count:
space: 5311
no_space: 24

* Lint/AmbiguousBlockAssociation

exclude `specs` folder

* Lint/AmbiguousOperator

exclude `Rakefile`

* Lint/AmbiguousRegexpLiteral

* Lint/DuplicateMethods

* Lint/SuppressedException

* Lint/UnderscorePrefixedVariableName

* Lint/UnusedBlockArgument

* Lint/UnusedMethodArgument

* Metrics/ModuleLength

* Metrics/ParameterLists

* Naming/HeredocDelimiterCase

* Style/BarePercentLiterals

* Style/BracesAroundHashParameters

* Style/ClassAndModuleChildren

* Style/CommentedKeyword

* Style/Encoding

* Style/GlobalVars

* Style/HashSyntax

* Style/InverseMethods

* Style/Lambda

* Style/LineEndConcatenation

* Style/NegatedIf

* Style/NumericLiterals

* Style/Proc

* Style/RaiseArgs

* Style/RedundantPercentQ

* Style/Semicolon

* Style/SingleLineMethods

Use exclude since auto-correction causes spec fail:
`rspec ./spec/rspec/rails_spec.rb:18`

* Layout/LineLength

* Style/NumericLiteralPrefix

* Style/RedundantSelf

* Style/EachWithObject

* Style/PerlBackrefs

Co-authored-by: Phil Pirozhkov <[email protected]>
@pirj pirj mentioned this pull request Jul 25, 2020
1 task
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.

3 participants