-
Notifications
You must be signed in to change notification settings - Fork 72
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
base: master
Are you sure you want to change the base?
RuboCop: Stage IV #171
Conversation
33b654b
to
9d62078
Compare
@@ -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) |
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.
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? } |
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.
Manual fix 2: looks safe to me
end | ||
rescue NameError | ||
raise InlineSvg::Configuration::Invalid.new("asset_file should implement the #named method") | ||
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.
suggestion: review with "hide whitespaces"
85766aa
to
609a448
Compare
@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 |
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.
Looks good overall. Not 100% sold on swapping inject
for each_with_object
. Keen to understand what the motivation for that change is. 🤔
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 |
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 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
. 🤔
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'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`
609a448
to
40c7a16
Compare
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 unsafemanual fix of
Style/HashConversion
Style/NonNilCheck
and subsequent switch fromselect !nil
toreject nil