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 updates #79

Merged
merged 9 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Lints

on:
on:
pull_request:
push:
branches:
Expand All @@ -9,18 +9,14 @@ on:
jobs:
build:

runs-on: ubuntu-18.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Install Dependencies
run: |
gem install bundler
bundle install
ruby-version: 3.0
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Lint files with Rubocop
run: |
rubocop
bundle exec rubocop
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require:
- rubocop-rspec

inherit_from: .rubocop_todo.yml

AllCops:
DisabledByDefault: false
NewCops: enable
TargetRubyVersion: 2.5

Lint/RaiseException:
Expand Down
214 changes: 131 additions & 83 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-05-05 23:22:20 -0400 using RuboCop version 0.81.0.
# on 2021-09-12 22:42:23 UTC using RuboCop version 1.20.0.
# 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.

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'lib/amazing_print/formatters/base_formatter.rb'

# Offense count: 4
# Configuration parameters: IgnoredMethods.
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/formats_spec.rb'
Expand All @@ -25,7 +18,7 @@ Lint/ImplicitStringConcatenation:
- 'amazing_print.gemspec'

# Offense count: 1
# Configuration parameters: AllowComments.
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Exclude:
- 'spec/support/ext_verifier.rb'
Expand All @@ -35,47 +28,42 @@ Lint/UselessAssignment:
Exclude:
- 'lib/amazing_print/ext/nobrainer.rb'

# Offense count: 14
# Configuration parameters: IgnoredMethods.
# Offense count: 12
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 46
Max: 48

# Offense count: 48
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
# Offense count: 51
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 665
Max: 667

# Offense count: 2
# Configuration parameters: CountComments.
# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 122
Max: 106

# Offense count: 12
# Offense count: 9
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 13

# Offense count: 22
# Configuration parameters: CountComments, ExcludedMethods.
# Offense count: 18
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 41

# Offense count: 12
# Offense count: 9
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 13
Max: 15

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'lib/amazing_print/formatters/base_formatter.rb'

# Offense count: 2
Naming/BinaryOperatorParameterName:
Exclude:
- 'lib/amazing_print/core_ext/awesome_method_array.rb'

# Offense count: 72
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Expand All @@ -95,7 +83,7 @@ Naming/HeredocDelimiterNaming:

# Offense count: 40
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/amazing_print/formatter.rb'
Expand All @@ -104,81 +92,141 @@ Naming/MethodParameterName:
- 'spec/methods_spec.rb'

# Offense count: 1
Security/Eval:
RSpec/AnyInstance:
Exclude:
- 'lib/amazing_print/core_ext/awesome_method_array.rb'
- 'spec/spec_helper.rb'

# Offense count: 8
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
# SupportedStyles: inline, group
Style/AccessModifierDeclarations:
# Offense count: 10
RSpec/BeforeAfterAll:
Exclude:
- 'lib/amazing_print/core_ext/kernel.rb'
- 'spec/support/ext_verifier.rb'
- 'spec/spec_helper.rb'
- 'spec/rails_helper.rb'
- 'spec/support/**/*.rb'
- 'spec/ext/mongo_mapper_spec.rb'
- 'spec/ext/mongoid_spec.rb'
- 'spec/ext/nobrainer_spec.rb'
- 'spec/ext/ripple_spec.rb'

# Offense count: 4
Style/ClassVars:
# Offense count: 16
# Configuration parameters: IgnoredMetadata.
RSpec/DescribeClass:
Exclude:
- 'lib/amazing_print/inspector.rb'
- 'spec/core_ext/logger_spec.rb'
- 'spec/core_ext/string_spec.rb'
- 'spec/ext/action_view_spec.rb'
- 'spec/ext/active_model_spec.rb'
- 'spec/ext/active_record_spec.rb'
- 'spec/ext/mongo_mapper_spec.rb'
- 'spec/ext/mongoid_spec.rb'
- 'spec/ext/nobrainer_spec.rb'
- 'spec/ext/nokogiri_spec.rb'
- 'spec/ext/ostruct_spec.rb'
- 'spec/ext/ripple_spec.rb'
- 'spec/ext/sequel_spec.rb'
- 'spec/methods_spec.rb'

# Offense count: 71
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 95

# Offense count: 3
Style/CommentedKeyword:
# Offense count: 115
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/colors_spec.rb'
- 'spec/ext/action_view_spec.rb'
- 'spec/ext/active_model_spec.rb'
- 'spec/ext/active_record_spec.rb'
- 'spec/ext/active_support_spec.rb'
- 'spec/ext/mongo_mapper_spec.rb'
- 'spec/ext/mongoid_spec.rb'
- 'spec/ext/nobrainer_spec.rb'
- 'spec/ext/ostruct_spec.rb'
- 'spec/ext/ripple_spec.rb'
- 'spec/ext/sequel_spec.rb'
- 'spec/formats_spec.rb'
- 'spec/misc_spec.rb'

# Offense count: 70
RSpec/LeakyConstantDeclaration:
Exclude:
- 'spec/colors_spec.rb'
- 'spec/ext/mongo_mapper_spec.rb'
- 'spec/ext/mongoid_spec.rb'
- 'spec/ext/nobrainer_spec.rb'
- 'spec/ext/ripple_spec.rb'
- 'spec/formats_spec.rb'
- 'spec/methods_spec.rb'
- 'spec/misc_spec.rb'
- 'spec/objects_spec.rb'

# Offense count: 30
Style/Documentation:
Enabled: false
# Offense count: 11
# Configuration parameters: .
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
EnforcedStyle: receive

# Offense count: 1
Style/EvalWithLocation:
RSpec/MultipleDescribes:
Exclude:
- 'lib/amazing_print/core_ext/awesome_method_array.rb'
- 'spec/methods_spec.rb'

# Offense count: 43
RSpec/MultipleExpectations:
Max: 20

# Offense count: 1
RSpec/NestedGroups:
Max: 4

# Offense count: 8
RSpec/RepeatedDescription:
Exclude:
- 'spec/formats_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/methods_spec.rb'

# Offense count: 2
RSpec/ScatteredSetup:
Exclude:
- 'spec/ext/nobrainer_spec.rb'

# Offense count: 6
RSpec/SubjectStub:
Exclude:
- 'spec/core_ext/logger_spec.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'lib/amazing_print/formatters/object_formatter.rb'
- 'spec/misc_spec.rb'

# Offense count: 1
# Configuration parameters: AllowIfModifier.
Style/IfInsideElse:
Security/Eval:
Exclude:
- 'spec/ext/active_record_spec.rb'
- 'lib/amazing_print/core_ext/awesome_method_array.rb'

# Offense count: 20
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/amazing_print.rb'
- 'lib/amazing_print/colorize.rb'
- 'lib/amazing_print/core_ext/logger.rb'
- 'lib/amazing_print/ext/active_record.rb'
- 'lib/amazing_print/ext/active_support.rb'
- 'lib/amazing_print/ext/mongo_mapper.rb'
- 'lib/amazing_print/ext/mongoid.rb'
- 'lib/amazing_print/ext/nobrainer.rb'
- 'lib/amazing_print/ext/nokogiri.rb'
- 'lib/amazing_print/ext/ostruct.rb'
- 'lib/amazing_print/ext/ripple.rb'
- 'lib/amazing_print/formatters/object_formatter.rb'
# Offense count: 5
Style/ClassVars:
Exclude:
- 'lib/amazing_print/inspector.rb'
- 'rails/init.rb'
- 'spec/spec_helper.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
# Offense count: 1
Style/DocumentDynamicEvalDefinition:
Exclude:
- 'spec/**/*'
- 'lib/amazing_print/formatters/base_formatter.rb'
- 'lib/amazing_print/formatters/hash_formatter.rb'
- 'lib/amazing_print/core_ext/awesome_method_array.rb'

# Offense count: 27
# Configuration parameters: AllowedConstants.
Style/Documentation:
Enabled: false

# Offense count: 258
# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Expand Down
4 changes: 2 additions & 2 deletions amazing_print.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Gem::Specification.new do |s|
s.version = AmazingPrint.version
s.required_ruby_version = '>= 2.5.0'
s.authors = ['Michael Dvorkin', 'Kevin McCormack' 'Patrik Wenger']
s.date = Time.now.strftime('%Y-%m-%d')
s.email = '[email protected]'
s.homepage = 'https://github.com/amazing-print/amazing_print'
s.summary = 'Pretty print Ruby objects with proper indentation and colors'
Expand All @@ -32,5 +31,6 @@ Gem::Specification.new do |s|
s.add_development_dependency 'nokogiri', '~> 1.10'
s.add_development_dependency 'pry'
s.add_development_dependency 'rspec', '~> 3.9'
s.add_development_dependency 'rubocop', '~> 0.81.0'
s.add_development_dependency 'rubocop', '~> 1.20'
s.add_development_dependency 'rubocop-rspec', '~> 2.4'
end
8 changes: 2 additions & 6 deletions lib/amazing_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@
# Load the following under normal circumstances as well as in Rails
# console when required from ~/.irbrc or ~/.pryrc.
#
if defined?(ActiveRecord) || AmazingPrint.rails_console?
require_relative 'amazing_print/ext/active_record'
end
if defined?(ActiveSupport) || AmazingPrint.rails_console?
require_relative 'amazing_print/ext/active_support'
end
require_relative 'amazing_print/ext/active_record' if defined?(ActiveRecord) || AmazingPrint.rails_console?
require_relative 'amazing_print/ext/active_support' if defined?(ActiveSupport) || AmazingPrint.rails_console?
#
# Load remaining extensions.
#
Expand Down
4 changes: 1 addition & 3 deletions lib/amazing_print/colorize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def colorize(str, type)
elsif str.method(options[:color][type]).arity == -1 # Accepts html parameter.
str.send(options[:color][type], options[:html])
else
if options[:html]
str = %(<kbd style="color:#{options[:color][type]}">#{str}</kbd>)
end
str = %(<kbd style="color:#{options[:color][type]}">#{str}</kbd>) if options[:html]
str.send(options[:color][type])
end
end
Expand Down
Loading