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 the latest rubocop #76

Merged
merged 1 commit into from
Sep 29, 2022

Conversation

akiomik
Copy link
Contributor

@akiomik akiomik commented Jan 26, 2021

I got the following error when I ran bundle exec rake with the latest version of rubocop, so I fixed it in this PR.

warning: parser/current is loading parser/ruby26, which recognizes                                                                                                               
warning: 2.6.6-compliant syntax, but you are running 2.6.0.                             
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.                                                                                            
Running RuboCop...                                                                                                                                                               
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout                                                                                                      
Error: The `Lint/HandleExceptions` cop has been renamed to `Lint/SuppressedException`.  
(obsolete configuration found in .rubocop_todo.yml, please update it)                                                                                                            
The `Naming/UncommunicativeMethodParamName` cop has been renamed to `Naming/MethodParameterName`.                                                                                
(obsolete configuration found in .rubocop_todo.yml, please update it)                                                                                                            
`Performance/*` has been extracted to the `rubocop-performance` gem.                                                                                                             
(obsolete configuration found in .rubocop_todo.yml, please update it)                                                                                                            
RuboCop failed!  
warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.6-compliant syntax, but you are running 2.6.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Running RuboCop...
.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.

Please also note that can also opt-in to new cops by default by adding this to your config:
  AllCops:
    NewCops: enable

Layout/SpaceBeforeBrackets: # (new in 1.7)
  Enabled: true
Lint/AmbiguousAssignment: # (new in 1.7)
  Enabled: true
Lint/DeprecatedConstants: # (new in 1.8)
  Enabled: true
Lint/DuplicateBranch: # (new in 1.3)
  Enabled: true
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
  Enabled: true
Lint/EmptyBlock: # (new in 1.1)
  Enabled: true
Lint/EmptyClass: # (new in 1.3)
  Enabled: true
Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
  Enabled: true
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
  Enabled: true
Lint/RedundantDirGlobSort: # (new in 1.8)
  Enabled: true
Lint/ToEnumArguments: # (new in 1.1)
  Enabled: true
Lint/UnexpectedBlockArity: # (new in 1.5)
  Enabled: true
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
  Enabled: true
Style/ArgumentsForwarding: # (new in 1.1)
  Enabled: true
Style/CollectionCompact: # (new in 1.2)
  Enabled: true
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
  Enabled: true
Style/EndlessMethod: # (new in 1.8)
  Enabled: true
Style/HashExcept: # (new in 1.7)
  Enabled: true
Style/NegatedIfElseCondition: # (new in 1.2)
  Enabled: true
Style/NilLambda: # (new in 1.3)
  Enabled: true
Style/RedundantArgument: # (new in 1.4)
  Enabled: true
Style/SwapValues: # (new in 1.1)
  Enabled: true
Performance/AncestorsInclude: # (new in 1.7)
  Enabled: true
Performance/BigDecimalWithNumericArgument: # (new in 1.7)
  Enabled: true
Performance/BlockGivenWithExplicitBlock: # (new in 1.9)
  Enabled: true
Performance/CollectionLiteralInLoop: # (new in 1.8)
  Enabled: true
Performance/ConstantRegexp: # (new in 1.9)
  Enabled: true
Performance/MethodObjectAsBlock: # (new in 1.9)
  Enabled: true
Performance/RedundantSortBlock: # (new in 1.7)
  Enabled: true
Performance/RedundantStringChars: # (new in 1.7)
  Enabled: true
Performance/ReverseFirst: # (new in 1.7)
  Enabled: true
Performance/SortReverse: # (new in 1.7)
  Enabled: true
Performance/Squeeze: # (new in 1.7)
  Enabled: true
Performance/StringInclude: # (new in 1.7)
  Enabled: true
Performance/Sum: # (new in 1.8)
  Enabled: true
For more information: https://docs.rubocop.org/rubocop/versioning.html
Inspecting 21 files
......W..C..C........

Offenses:

lib/rantly/generator.rb:3:5: C: [Correctable] Layout/EmptyLinesAroundAttributeAccessor: Add an empty line after attribute accessor.
    attr_writer :default_size
    ^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rantly/generator.rb:34:5: W: Lint/MissingSuper: Call super to initialize state of the parent class.
    def initialize(limit, nfailed) ...
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rantly/generator.rb:194:3: C: Metrics/CyclomaticComplexity: Cyclomatic complexity for freq is too high. [9/7]
  def freq(*pairs) ...
  ^^^^^^^^^^^^^^^^
lib/rantly/generator.rb:194:3: C: Metrics/PerceivedComplexity: Perceived complexity for freq is too high. [9/8]
  def freq(*pairs) ...
  ^^^^^^^^^^^^^^^^
lib/rantly/property.rb:8:19: C: [Correctable] Style/RedundantFetchBlock: Use fetch('RANTLY_VERBOSE', 1) instead of fetch('RANTLY_VERBOSE') { 1 }.
  VERBOSITY = ENV.fetch('RANTLY_VERBOSE') { 1 }.to_i
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rantly/property.rb:9:22: C: [Correctable] Style/RedundantFetchBlock: Use fetch('RANTLY_COUNT', 100) instead of fetch('RANTLY_COUNT') { 100 }.
  RANTLY_COUNT = ENV.fetch('RANTLY_COUNT') { 100 }.to_i
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/rantly/property.rb:13:15: C: [Correctable] Style/GlobalStdStream: Use $stdout instead of STDOUT.
              STDOUT
              ^^^^^^
lib/rantly/property.rb:44:25: C: [Correctable] Naming/RescuedExceptionsVariableName: Use e instead of boom.
    rescue Exception => boom
                        ^^^^
lib/rantly/shrinks.rb:4:5: C: [Correctable] Style/RedundantAssignment: Redundant assignment before returning detected.
    shrunk = if self > 8 ...
    ^^^^^^^^^^^^^^^^^^^^

21 files inspected, 9 offenses detected, 6 offenses auto-correctable

Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
  * rubocop-minitest (http://github.com/rubocop-hq/rubocop-minitest)
  * rubocop-rake (http://github.com/rubocop-hq/rubocop-rake)

You can opt out of this message by adding the following to your config (see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
  AllCops:
    SuggestExtensions: false
RuboCop failed!

Copy link
Contributor

@diasbruno diasbruno left a comment

Choose a reason for hiding this comment

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

It would be nice to also add to the test matrix recent ruby versions.

@abargnesi
Copy link
Member

Hi Akiomi. Thanks for the contribution to updating rubocop. Great idea.

@abargnesi abargnesi merged commit 26e3f79 into rantly-rb:master Sep 29, 2022
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