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

RuboCop: Stage IV #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tagliala
Copy link
Contributor

@tagliala tagliala commented Oct 10, 2024

Requires #170

I've tried to only fix objective or almost-objective offenses, if you don't like some of the fixes let me know.

There are very few changes to production code


This PR fixes:

  • Layout/DotPosition
  • Lint/AmbiguousOperator
  • Lint/LiteralInInterpolation
  • RSpec/BeEmpty
  • RSpec/ContextMethod
  • RSpec/HookArgument
  • RSpec/MatchArray
  • RSpec/NotToNot
  • Style/EachWithObject
  • Style/ExpandPathArguments
  • Style/HashSyntax
  • Style/NestedParenthesizedCalls
  • Style/RedundantBegin
  • Style/RedundantConstantBase
  • Style/RedundantReturn
  • Style/RegexpLiteral

Some manual fixes:

  • Lint/RedundantSplatExpansion and subsequent unsafe
    manual fix of Style/HashConversion
  • Style/NonNilCheck and subsequent switch from
    select !nil to reject nil

@@ -66,7 +65,7 @@ def add_custom_transformation(options)
raise InlineSvg::Configuration::Invalid.new("#{options.fetch(:transform)} should implement the .create_with_value and #transform methods")
end

@custom_transformations.merge!(Hash[*[options.fetch(:attribute, :no_attribute), options]])
@custom_transformations.merge!(options.fetch(:attribute, :no_attribute) => options)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Manual fix 1: looks safe to me

@@ -65,7 +64,7 @@ def self.without_empty_values(params)
def self.all_default_values
custom_transformations
.values
.select { |opt| opt[:default_value] != nil }
.reject { |opt| opt[:default_value].nil? }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Manual fix 2: looks safe to me

end
rescue NameError
raise InlineSvg::Configuration::Invalid.new("asset_file should implement the #named method")
end
Copy link
Contributor Author

@tagliala tagliala Oct 10, 2024

Choose a reason for hiding this comment

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

suggestion: review with "hide whitespaces"

@tagliala tagliala force-pushed the chore/rubocop-stage-iv branch 3 times, most recently from 85766aa to 609a448 Compare October 11, 2024 06:45
@tagliala
Copy link
Contributor Author

@jamesmartin rebased and ready for review

Most of the changes are related to non-production code

There are two changes on production code with a manual fix, they have a comment and I'm quite positive they are safe

Copy link
Owner

@jamesmartin jamesmartin left a comment

Choose a reason for hiding this comment

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

Looks good overall. Not 100% sold on swapping inject for each_with_object. Keen to understand what the motivation for that change is. 🤔

Comment on lines 27 to 31
transforms.inject({}) do |output, (name, definition)|
transforms.each_with_object({}) do |(name, definition), output|
priority = definition.fetch(:priority, built_in_transformations.size)

output[name] = definition.merge({ priority: magnify(priority) })
output
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure about this one. I know some people don't like that it's necessary to remember to return the memo object from the block but I've never loved the explicit mutability of the object in each_with_object. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've disabled this cop with a reference to this comment and force pushed

- `Layout/DotPosition`
- `Lint/AmbiguousOperator`
- `Lint/LiteralInInterpolation`
- `RSpec/BeEmpty`
- `RSpec/ContextMethod`
- `RSpec/HookArgument`
- `RSpec/MatchArray`
- `RSpec/NotToNot`
- `Style/ExpandPathArguments`
- `Style/HashSyntax`
- `Style/NestedParenthesizedCalls`
- `Style/RedundantBegin`
- `Style/RedundantConstantBase`
- `Style/RedundantReturn`
- `Style/RegexpLiteral`

Some manual fixes:
- `Lint/RedundantSplatExpansion` and subsequent unsafe
  manual fix of `Style/HashConversion`
- `Style/NonNilCheck` and subsequent switch unsafe manual fix of
  `Style/InverseMethods`
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