rubocop_plus 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9339fafc44664971f7130176d7f8e219300d6040c129571c5133a6899b294c54
4
+ data.tar.gz: f11445ad0bc0ad86dadcdf98809f9973449b1fdd4f3d4a80b36d1f6d7d9f7930
5
+ SHA512:
6
+ metadata.gz: 4121486fdc872b3a3eefbc04a0d77cfe69bbc257b46aa53dfbbd428729f0fae36b71584b3a6824dba908a9d205169fde7b33a8b9a5734318dd96d308828b7c5e
7
+ data.tar.gz: 885d103f4ee897ede61a19be1560b8dcf9efb4d9aa13585a8d24c06a37b7b553dfb3b8dff1bb3370b007191faf6cb3f4ee1264287b959274a5e89b5cc6aa0016
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # Ignore output from rspec_n gem
14
+ rspec_n_iteration.*
15
+
16
+ /rubocop/
17
+ /Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ inherit_from:
2
+ - config/rubocop.yml
3
+
4
+ Rails:
5
+ Enabled: false
@@ -0,0 +1,14 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 2.3.8
6
+ - 2.4.9
7
+ - 2.5.7
8
+ - 2.6.5
9
+ - 2.7.0
10
+ before_install: gem install bundler -v 2.1.4
11
+ notifications:
12
+ email:
13
+ on_success: never # default: change
14
+ on_failure: never # default: always
@@ -0,0 +1,57 @@
1
+ # CHANGELOG
2
+
3
+ Issues are tracked at https://github.com/roberts1000/rubocop_plus/issues. Changes marked as **(Internal)** support development or refactoring.
4
+
5
+ ## 1.11.0 (Jan 31, 2020)
6
+
7
+ 1. [#58](../../issues/58): Disable the `RSpec/FilePath` cop.
8
+
9
+ ## 1.10.0 (Jan 31, 2020)
10
+
11
+ 1. [#54](../../issues/54): Disable the `RSpec/DescribedClass` cop.
12
+
13
+ ## 1.9.0 (Jan 31, 2020)
14
+
15
+ 1. [#50](../../issues/50): Allow `feature` and `scenario` with the `Capybara/FeatureMethods` cop.
16
+
17
+ ## 1.8.0 (Jan 31, 2020)
18
+
19
+ 1. [#46](../../issues/46): Make `RSpec/NotToNot` use `to_not`.
20
+
21
+ ## 1.7.0 (Jan 31, 2020)
22
+
23
+ 1. [#37](../../issues/37): Use lists in the `CHANGELOG.md`. **(Internal)**
24
+ 1. [#39](../../issues/39): Add Ruby 2.7 support.
25
+ 1. [#42](../../issues/42): Disable `RSpec/InstanceVariable`.
26
+
27
+ ## 1.6.0 (Jan 13, 2020)
28
+
29
+ 1. [#29](../../issues/29): Use new rspec_starter interface.
30
+ 1. [#31](../../issues/31): Disable the `RSpec/MultipleExpectations` cop.
31
+ 1. [#33](../../issues/33): Set `RSpec/ExampleLength` `Max` to 8.
32
+
33
+ ## 1.5.0 (Jan 13, 2020)
34
+
35
+ 1. [#25](../../issues/25): Add `rubocop-rspec ~> 1.37.1`.
36
+
37
+ ## 1.4.0 (Jan 07, 2020)
38
+
39
+ 1. [#21](../../issues/21): Use `rubocop 0.79.0`.
40
+
41
+ ## 1.3.0 (Jan 03, 2020)
42
+
43
+ 1. [#13](../../issues/13): Use `rubocop 0.78.0`.
44
+ 1. [#15](../../issues/15): Use `rspec ~> 3.9.0` for development. **(Internal)**
45
+ 1. [#17](../../issues/17): Use `rake ~> 13.0` for development. **(Internal)**
46
+
47
+ ## 1.2.0 (Jan 02, 2020)
48
+
49
+ 1. [#9](../../issues/9): Use `rubocop-performance ~> 1.5.2`.
50
+
51
+ ## 1.1.0 (Dec 29, 2019)
52
+
53
+ 1. [#5](../../issues/5): Use `rubocop-rails ~> 2.4.1`.
54
+
55
+ ## 1.0.0 (Aug 19, 2019)
56
+
57
+ 1. [#1](../../issues/1): Create initial release using rubocop 0.74.0.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in rubocop_plus.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'rspec_starter', "~> 1.5", require: false
10
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 roberts1000
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,73 @@
1
+ # rubocop_plus
2
+
3
+ rubocop_plus is a gem that wraps around the community [rubocop gem](https://github.com/bbatsov/rubocop). It makes changes and enhancements to the base rubocop gem by altering configuration and code. All configuration changes can be found in the `config` folder.
4
+
5
+ #### Disclaimer
6
+
7
+ rubocop_plus was built as a place to store **my preferred** rubocop configuration and enhancements, in a single location. **There is absolutely no association with the base rubocop project.** rubocop_plus was made public so it could be shared between multiple organizations that I support, and to serve as a reference gem to anyone who wants to do some similar.
8
+
9
+ ## Version Policy
10
+
11
+ Releases are versioned using [semver 2.0.0](https://semver.org/spec/v2.0.0.html).
12
+
13
+ ## Installation
14
+
15
+ You can install rubocop_plus manually by performing
16
+
17
+ $ gem install rubocop_plus
18
+
19
+ You can also place rubocop_plus in your project's Gemfile
20
+
21
+ ```ruby
22
+ gem 'rubocop_plus'
23
+ ```
24
+
25
+ Remove rubocop from the project's Gemfile and Gemfile.lock. rubocop_plus will install the version of rubocop that it wants to use.
26
+
27
+ Then run
28
+
29
+ $ bundle
30
+
31
+ Initialize your project's rubocop configuration
32
+
33
+ $ rubo --init
34
+
35
+ This will create a specially configured `.rubocop.yml` inside the project root.
36
+
37
+ **Note:** Keep in mind, if you place rubocop_plus in a projects Gemfile, it will **lock** your project to the version of rubocop_plus that gets written to the Gemfile.lock file. If you're using a continuous integration platform, like Jenkins or Travis, this will likely restrict the CI tool to that same version - which is not always ideal. Some people prefer to have the CI platform **tell** the project which version of rubocop_plus to use. In that case, you should not put the rubocop_plus in the project's Gemfile.
38
+
39
+ ## Usage
40
+
41
+ `rubocop_plus` provides a `rubo` command that you can use run to invoke rubocop in a standard manner. It will write all output to the `rubocop` folder inside the project. You can run `rubo --help` to see a list of commands. If rubocop_plus is included the project's Gemfile, rubo will execute the locked version. Otherwise, it will execute the latest version on the system.
42
+
43
+ #### Total Violation Count
44
+
45
+ The `rubo` command will create a `rubocop/total-violations-count.txt file` as part of the output. This file holds a single number that represents the total number of violations that were found by rubocop. This file was created so continuous integration tools like Jenkins or Travis could be configured to fail builds that have "too many" violations.
46
+
47
+ #### Specifying the Correct Ruby
48
+
49
+ rubocop needs to know which version of ruby to use to have a basis for evaluating your application. rubocop_plus does not perform any magic here, but we offer a recommendation on how to proceed:
50
+
51
+ 1. Make sure your `.rubocop.yml` does not include the `TargetRubyVersion` key under `AllCops:`. If it is present, rubocop will always use that value.
52
+ 1. Create a `.ruby-version` file and define your ruby version inside this file. The file should have a single value specifying the full ruby version (i.e 2.5.0).
53
+ 1. Specify the `ruby` version in the Gemfile by adding `ruby File.read('.ruby-version', mode: 'rb').chomp` to the Gemfile. This will avoid duplication by reading the value out of the `.ruby-version` file.
54
+
55
+ As of rubocop 0.52.1 (01/15/2018), rubocop does not look at the Gemfile to determine the ruby version. Hopefully that will change in the future. Until then, rubocop will pull the value out of the `.ruby-version` file and other services can read the value from `.ruby-version` or the `Gemfile`.
56
+
57
+ ## Development
58
+
59
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ The easiest way to test the gem locally is to `cd` into a ruby project that can serve as a test bed. From the sample project's root folder, execute `rubo` by typing the relative (or full path) to the `rubo` command where you cloned the rubocop_plus project. If your sample_app and rubocop_plus folder were in the same parent folder, your command would look like `../rubocop_plus/exe/rubo`.
62
+
63
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+
65
+ To run rubocop_plus on itself, `cd` to the root of `rubocop_plus` and run `exe/rubo`. If you just run `rubo`, you'll be invoking the version of `rubo` that was installed by the latest installed version of the gem...not the version of `rubo` within the development folder of the gem.
66
+
67
+ ## Contributing
68
+
69
+ Contributions are welcome, but please be aware that rubocop_plus was created to serve the projects and teams that I directly support. Their needs and style preferences will always come first. To contribute, create an issue on the [GitHub Issue board](https://github.com/roberts1000/rubocop_plus/issues) and wait for feedback. Once the idea is approved, submit a Pull Request.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ exec "pry -r rubocop_plus -I ./lib"
10
+ # exec "irb -r rubocop_plus -I ./lib"
11
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rubocop_plus"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
12
+
13
+ # require "irb"
14
+ # IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Execute this script to run RSpec for the app.
4
+ # To run all specs, navigate to the application's root folder and execute
5
+ # bin/start_rspec
6
+ # rspec_starter takes command line options and forwards unknown options to rspec
7
+ # bin/start_rspec --no-prep-db spec/features
8
+ # See the help output for more advanced ways to run the script
9
+ # bin/start_rspec --help
10
+
11
+ require "bundler/setup"
12
+ require "rspec_starter"
13
+
14
+ # The path to the application's root folder.
15
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
16
+
17
+ # Create a custom task. For more information about custom tasks, see
18
+ # https://github.com/roberts1000/rspec_starter. Once defined, add
19
+ # 'task :my_custom_task' to the start block to execute.
20
+ #
21
+ # class MyCustomTask < RspecStarterTask
22
+ # # Specify a message to show users when the task executes.
23
+ # def starting_message
24
+ # "Executing My Custom Task"
25
+ # end
26
+ #
27
+ # # Execute task code.
28
+ # def execute
29
+ # end
30
+ # end
31
+
32
+ # Tasks are run from the top down.
33
+ RspecStarter.start do
34
+ task :verify_display_server
35
+ task :remove_tmp_folder
36
+ task :start_rspec
37
+ end
@@ -0,0 +1,81 @@
1
+ # Layout/ArgumentAlignment checks alignment of arguments in multi-line method calls. rubocop defaults to `with_first_parameter`
2
+ # which expects:
3
+ #
4
+ # method_call(a,
5
+ # b)
6
+ #
7
+ # rubocop_plus prefers the indented style
8
+ #
9
+ # method_call(a,
10
+ # b)
11
+ Layout/ArgumentAlignment:
12
+ EnforcedStyle: with_fixed_indentation # with_first_parameter is the default
13
+
14
+ # Layout/AlignParameters checks alignment of parameters in multi-line method calls. rubocop defaults to `with_first_parameter`
15
+ # which expects:
16
+ #
17
+ # method_call(a,
18
+ # b)
19
+ #
20
+ # rubocop_plus prefers the indented style
21
+ #
22
+ # method_call(a,
23
+ # b)
24
+ Layout/ParameterAlignment:
25
+ EnforcedStyle: with_fixed_indentation # with_first_parameter is the default
26
+
27
+ # This cop checks the indentation of the right hand side operand in operations that span more than one line.
28
+ # Rubocop defaults to 'aligned'.
29
+ #
30
+ # if first_method +
31
+ # second_method +
32
+ # third_method
33
+ # end
34
+ #
35
+ # Prefer the 'indented' style.
36
+ #
37
+ # if first_method +
38
+ # second_method +
39
+ # third_method
40
+ # end
41
+ Layout/MultilineOperationIndentation:
42
+ EnforcedStyle: indented # aligned is the default
43
+ IndentationWidth: 3 # the default seems to be 2 which makes methods indent 1 space past the first method
44
+
45
+ # Layout/MultilineMethodCallIndentation checks the indentation of chained method calls. rubocop defaults to 'aligned':
46
+ #
47
+ # SomeReallyExceptionallyLongClassName.some_exceptionally_long_method_number_1(plus_variable_one, variable_two_...)
48
+ # .some_exceptionally_long_method_number_2(plus_variable_one, variable_two_...)
49
+ #
50
+ # This can easily cause line length length violations (particularly with ActiveRecord queries), plus it wastes alot of white
51
+ # space at the beginning. The 'indented' style is preferred since it is more compact (although it uses an extra line).
52
+ #
53
+ # SomeReallyExceptionallyLongClassName
54
+ # .some_exceptionally_long_method_number_1(plus_variable_one, variable_two_...)
55
+ # .some_exceptionally_long_method_number_2(plus_variable_one, variable_two_...)
56
+ #
57
+ # This has the added benefit of oriented the method calls directly under the object which is receiving the message, which
58
+ # is more readable.
59
+ Layout/MultilineMethodCallIndentation:
60
+ EnforcedStyle: indented
61
+
62
+ # This cop checks for spaces around the '=' sign in a method's attribute list. Prefer no spaces since it more compact.
63
+ #
64
+ # = Recommended = = Default =
65
+ # def the_method(foo=1) vs def the_method(foo = 1)
66
+ Layout/SpaceAroundEqualsInParameterDefault:
67
+ EnforcedStyle: no_space
68
+
69
+ # Metrics/LineLength checks the length of lines. The 80 character default to too restrictive. It does have the advantage of
70
+ # saving horizontal screen space, which is useful for some layouts/workflows. However, it has some issues:
71
+ # 1. It doesn't take advantage of available horizontal screen width, which is widely available due to the proliferation
72
+ # wide screen monitors.
73
+ # 2. It adds more lines to a class, which makes it more likely that rubocop's ClassLength cop will be exceeded.
74
+ # 3. Ruby code only represents part of a web application. It is acceptable for HTML in the view to frequently exceed 80
75
+ # characters and it is typically uses word-wrap which doesn't use ANY width limits. View code represents a large portion
76
+ # of an application; if it is going to regularly exceed 80, why restrict the Ruby code to 80?
77
+ # 4. Many other projects, like Rails, exceed 80 so it doesn't appear to be a hard standard (at least not anymore).
78
+ # As a result, a larger line length was adopted to strike a better balance between, readability, scrolling frequency and
79
+ # layout concerns.
80
+ Layout/LineLength:
81
+ Max: 130 # default is 80.
@@ -0,0 +1,4 @@
1
+ # Some 3rd party bin files suppress exceptions. Ignore them since the code doesn't originate in the project.
2
+ Lint/SuppressedException:
3
+ Exclude:
4
+ - bin/spring
@@ -0,0 +1,29 @@
1
+ # This cop checks that the ABC size of methods is not higher than the configured maximum. The current default is a little
2
+ # low and produces many false positives.
3
+ Metrics/AbcSize:
4
+ Max: 40 # The default is 15.
5
+
6
+ # Metrics/BlockLength checks the lines in a block. The default is 25.
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - spec/**/* # The RSpec DSL uses large blocks.
10
+ - db/migrate/**/* # The Rails migrate folder has large blocks.
11
+ - config/routes.rb # The Rails routes file is one large block.
12
+
13
+ # Metrics/ClassLength checks the number of lines in a class.
14
+ Metrics/ClassLength:
15
+ Max: 200 # 100 is the default which is too restrictive.
16
+
17
+ # Metrics/MethodLength checks the number of lines in a method.
18
+ Metrics/MethodLength:
19
+ Max: 15
20
+ Exclude: # skip all of the following....
21
+ - db/migrate/**/*
22
+
23
+ # Metrics/ModuleLength checks the number of lines in a module.
24
+ Metrics/ModuleLength:
25
+ Max: 200 # 100 is the default which is too restrictive.
26
+
27
+ # Metrics/ParameterLists validates the number of parameters that a method can take.
28
+ Metrics/ParameterLists:
29
+ Max: 7 # The default limit is 5 which is a bit restrictive.
@@ -0,0 +1,4 @@
1
+ # This cop checks for the use of 'is_', 'has_' and 'have_' in front of methods. By default, it recommends that they be removed.
2
+ # Predicates are useful in many situations. It's conterproductive to enforce a single style.
3
+ Naming/PredicateName:
4
+ Enabled: false
@@ -0,0 +1,7 @@
1
+ # Rails/FilePath ensures Rails.root.join('path', 'to') is used instead of "#{Rails.root}/path/to". This cop isn't necessary
2
+ # since Ruby will automatically convert file path separators.
3
+ Rails/FilePath:
4
+ Enabled: false
5
+
6
+ Performance/RedundantMerge:
7
+ Enabled: false
@@ -0,0 +1,37 @@
1
+ # Blocks the use of Capybara style methods like `feature`, `scenario, `given`, etc... Allow the use of some of these methods.
2
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/capybara/feature_methods.rb
3
+ Capybara/FeatureMethods:
4
+ EnabledMethods:
5
+ - feature
6
+ - scenario
7
+
8
+ # Checks if the first element of a describe block is a class and if described_class is used in examples. Prefer the flexibility
9
+ # of using strings with `describe` and putting the described class directly in an example.
10
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/described_class.rb
11
+ RSpec/DescribedClass:
12
+ Enabled: false
13
+
14
+ # Checks the number of lines in the spec example. The default is 5, which frequently can be a bit tight.
15
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/example_length.rb#L28
16
+ RSpec/ExampleLength:
17
+ Max: 8
18
+
19
+ # Checks that spec file paths are consistent with the test subject. Cop is too strict.
20
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/file_path.rb
21
+ RSpec/FilePath:
22
+ Enabled: false
23
+
24
+ # Checks for the use of instance variables in specs. Prefer allowing instance variables ('let' should be used when possible).
25
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/instance_variable.rb
26
+ RSpec/InstanceVariable:
27
+ Enabled: false
28
+
29
+ # Checks for multiple expectations in a test. Prefer allowing any number of expecations.
30
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/multiple_expectations.rb#L48
31
+ RSpec/MultipleExpectations:
32
+ Enabled: false
33
+
34
+ # Checks for the use of not_to instead of to_not. Prefer to_not.
35
+ # https://github.com/rubocop-hq/rubocop-rspec/blob/v1.37.1/lib/rubocop/cop/rspec/not_to_not.rb
36
+ RSpec/NotToNot:
37
+ EnforcedStyle: to_not