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

Exclude gemspec file by default for Metrics/BlockLength #6810

Conversation

koic
Copy link
Member

@koic koic commented Mar 5, 2019

This PR excludes gemspec file by default for Metrics/BlockLength cop.

When gemspec file is changed, it is mainly the increase / decrease for add_runtime_dependency and add_development_dependency.
There is no tendency to change with complicated logic.

Also gemspec file made with bundle gem is also warned by default.

% bundle -v
Bundler version 2.0.1
% bundle gem foo
Creating gem 'foo'...
MIT License enabled in config
      create  foo/Gemfile
      create  foo/lib/foo.rb
      create  foo/lib/foo/version.rb
      create  foo/foo.gemspec
      create  foo/Rakefile
      create  foo/README.md
      create  foo/bin/console
      create  foo/bin/setup
      create  foo/.gitignore
      create  foo/.travis.yml
      create  foo/.rspec
      create  foo/spec/spec_helper.rb
      create  foo/spec/foo_spec.rb
      create  foo/LICENSE.txt
Initializing git repo in /private/tmp/foo

% rubocop -v
0.65.0
% rubocop --only Metrics/BlockLength
Inspecting 8 files
C.......

Offenses:

foo.gemspec:6:1: C: Metrics/BlockLength: Block has too many
lines. [26/25]
Gem::Specification.new do |spec| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

8 files inspected, 1 offense detected

Therefore this PR excluded gemspec file by default.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@@ -1643,13 +1643,15 @@ Metrics/BlockLength:
Description: 'Avoid long blocks with many lines.'
Enabled: true
VersionAdded: '0.44'
VersionChanged: '0.58'
VersionChanged: '0.66'
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 I change VersionChanged to change the default setting. I think that the next release when merging this will be 0.66.0.

@koic koic force-pushed the exclude_gemspec_by_default_for_metrics_block_length branch from 1b7a6f1 to 731826a Compare March 5, 2019 09:25
This PR excludes gemspec file by default for `Metrics/BlockLength` cop.

When gemspec file is changed, it is mainly the increase / decrease for
`add_runtime_dependency` and `add_development_dependency`.
There is no tendency to change with complicated logic.

Also gemspec file made with `bundle gem` is also warned by default.

```console
% bundle -v
Bundler version 2.0.1
% bundle gem foo
Creating gem 'foo'...
MIT License enabled in config
      create  foo/Gemfile
      create  foo/lib/foo.rb
      create  foo/lib/foo/version.rb
      create  foo/foo.gemspec
      create  foo/Rakefile
      create  foo/README.md
      create  foo/bin/console
      create  foo/bin/setup
      create  foo/.gitignore
      create  foo/.travis.yml
      create  foo/.rspec
      create  foo/spec/spec_helper.rb
      create  foo/spec/foo_spec.rb
      create  foo/LICENSE.txt
Initializing git repo in /private/tmp/foo

% rubocop -v
0.65.0
% rubocop --only Metrics/BlockLength
Inspecting 8 files
C.......

Offenses:

foo.gemspec:6:1: C: Metrics/BlockLength: Block has too many
lines. [26/25]
Gem::Specification.new do |spec| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

8 files inspected, 1 offense detected
```

Therefore this PR excluded gemspec file by default.
@koic koic force-pushed the exclude_gemspec_by_default_for_metrics_block_length branch from 731826a to ac4c7bc Compare March 5, 2019 09:30
@Drenmi Drenmi merged commit 4654809 into rubocop:master Mar 6, 2019
@Drenmi
Copy link
Collaborator

Drenmi commented Mar 6, 2019

🙇

@koic koic deleted the exclude_gemspec_by_default_for_metrics_block_length branch March 6, 2019 03:49
koic added a commit to rubocop/rubocop-rails that referenced this pull request Jul 18, 2019
And apply `bundle exec rubocop --auto_gen_config`.
rubocop/rubocop#6810
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.

None yet

3 participants