armitage-rubocop 0.85.1

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: 801ba79bcde3092cf474495c6193f0741ecf7255aa6823e03bd040c6ee99416b
4
+ data.tar.gz: 30d05d1f766efdebb0358b5ef85b515722bb218c47bfd031eb5a14997a09286f
5
+ SHA512:
6
+ metadata.gz: 7a2c4f90aeec589490828b9548a14647c8d418e0e8ba3f124337bd6927b3a4128471b54221b90221d72acbd270859c8ee6ffae0cb0171d35cc5f40253a0e221b
7
+ data.tar.gz: a6386d38de5ad307b23b5aa24e98b7afb120822914d623d84bb5827e6d04b62990458d47c2639935438b5b85fbeb99e0341aa53b0dfcf2597a82a9d3acddcb3f
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .rspec_status
10
+ /Gemfile.lock
11
+ .ruby-version
12
+ gemfiles/*.lock
13
+ *.gem
@@ -0,0 +1,6 @@
1
+ inherit_from:
2
+ - ./lib/rubocop.general.yml
3
+ - ./lib/rubocop.rake.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7.1
@@ -0,0 +1,50 @@
1
+ extends: default
2
+
3
+ yaml-files:
4
+ - '*.yml'
5
+ - '*.yaml'
6
+
7
+ rules:
8
+ braces:
9
+ min-spaces-inside: 1
10
+ max-spaces-inside: 1
11
+ min-spaces-inside-empty: 0
12
+ max-spaces-inside-empty: 0
13
+ brackets:
14
+ min-spaces-inside: 0
15
+ max-spaces-inside: 0
16
+ min-spaces-inside-empty: 0
17
+ max-spaces-inside-empty: 0
18
+ colons:
19
+ max-spaces-before: 0
20
+ max-spaces-after: 1
21
+ commas:
22
+ max-spaces-before: 0
23
+ min-spaces-after: 1
24
+ max-spaces-after: 1
25
+ comments: disable
26
+ comments-indentation: {}
27
+ document-start: disable
28
+ document-end: disable
29
+ empty-lines:
30
+ max: 1
31
+ empty-values: disable
32
+ hyphens:
33
+ max-spaces-after: 1
34
+ indentation:
35
+ spaces: 2
36
+ indent-sequences: whatever
37
+ check-multi-line-strings: true
38
+ key-duplicates: {}
39
+ key-ordering: disable
40
+ line-length:
41
+ max: 150
42
+ allow-non-breakable-words: false
43
+ new-line-at-end-of-file: enable
44
+ new-lines:
45
+ type: unix
46
+ octal-values:
47
+ forbid-explicit-octal: true
48
+ quoted-strings: disable
49
+ trailing-spaces: {}
50
+ truthy: {}
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at iamdaiver@icloud.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source('https://rubygems.org')
4
+
5
+ # Specify your gem's dependencies in armitage.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018-2020 Rustam Ibragimov
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,86 @@
1
+ # armitage-rubocop · [![Gem Version](https://badge.fury.io/rb/armitage-rubocop.svg)](https://badge.fury.io/rb/armitage-rubocop)
2
+
3
+ - [Installation](#installation)
4
+ - [Usage](#usage)
5
+ - [Build](#build)
6
+
7
+ ---
8
+
9
+ Configured rules:
10
+
11
+ - **Common** (`.rubocop.general.yml`) (`.rubocop.rails.yml`) (`.rubocop.rake.yml`)
12
+ - Bundler
13
+ - Rake
14
+ - Gemspec
15
+ - Layout
16
+ - Lint
17
+ - Metrics
18
+ - Migration
19
+ - Naming
20
+ - Performance
21
+ - Rails (isn't included in `.rubocop.general.yml`)
22
+ - Security
23
+ - Style
24
+ - Rake (isn't included in `.rubocop.general.yml`)
25
+ - **RSpec** (`.rubocop.rspec.yml`) (`.rubocop.rails.yml`)
26
+ - Capybara
27
+ - FactoryBot
28
+ - Rails
29
+ - RSpec
30
+
31
+ ---
32
+
33
+ ### Installation
34
+ ```ruby
35
+ gem 'armitage-rubocop'
36
+ ```
37
+
38
+ ```shell
39
+ $ bundle install
40
+ # --- or ---
41
+ $ gem install 'armitage-rubocop'
42
+ ```
43
+
44
+ ```ruby
45
+ require 'armitage-rubocop'
46
+ ```
47
+
48
+ ---
49
+
50
+ ### Usage
51
+
52
+ - edit your `.rubocop.yml` file:
53
+
54
+ ```yaml
55
+ # --- vanilla ---
56
+ inherit_gem:
57
+ armitage-rubocop:
58
+ - lib/rubocop.general.yml
59
+ - lib/rubocop.rspec.yml
60
+ - lib/rubocop.rake.yml
61
+ ```
62
+
63
+ ```yaml
64
+ # --- rails ---
65
+ inherit_gem:
66
+ # rails-specific cops + general + rspec
67
+ armitage-rubocop: lib/rubocop.rails.yml
68
+ ```
69
+
70
+ ---
71
+
72
+ ### Build
73
+
74
+ ```ruby
75
+ # --- full build ---
76
+ bundle exec rake armitage_rubocop:build
77
+
78
+ # --- validate code style ---
79
+ bundle exec rake rubocop
80
+
81
+ # --- validate yaml files ---
82
+ bundle exec rake armitage_rubocop:validation:valid_yamls
83
+
84
+ # --- validate rubocop cops (existence and params) ---
85
+ bundle exec rake armitage_rubocop:validation:recognizable_cops
86
+ ```
@@ -0,0 +1,138 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rubocop/rake_task'
5
+ require 'open3'
6
+ require 'yaml'
7
+ require 'rubocop'
8
+ require 'rubocop-rails'
9
+ require 'rubocop-performance'
10
+ require 'rubocop-rspec'
11
+ require 'rubocop-rake'
12
+
13
+ RuboCop::RakeTask.new(:rubocop) do |t|
14
+ config_path = File.expand_path(File.join('.rubocop.yml'), __dir__)
15
+ t.options = ['--config', config_path]
16
+ t.requires << 'rubocop-rspec'
17
+ t.requires << 'rubocop-performance'
18
+ t.requires << 'rubocop-rails'
19
+ t.requires << 'rubocop-rake'
20
+ end
21
+
22
+ NON_CHECKABLE_COPS = %w[Rails].freeze # NOTE: Global "Rails" cop has only `Enabled` option
23
+
24
+ # rubocop:disable Rails/RakeEnvironment
25
+ namespace :armitage_rubocop do
26
+ desc 'Full armitage-rubocop build (code style, cops validation, yaml validation)'
27
+ task :build do
28
+ build_processes = {
29
+ code_style_check:
30
+ Open3.popen3('bundle exec rake rubocop'),
31
+ cops_validation:
32
+ Open3.popen3('bundle exec rake armitage_rubocop:validation:recognizable_cops'),
33
+ yaml_validation:
34
+ Open3.popen3('bundle exec rake armitage_rubocop:validation:valid_yamls')
35
+ }
36
+
37
+ # NOTE: results structure { type => exit_code }
38
+ results = {}.tap do |result_data|
39
+ build_processes.each_pair do |build_type, build_process|
40
+ # NOTE: build_process => [stdin, stdout, stderr, wtr]
41
+ build_result = build_process[3].value.exitstatus
42
+ result_data[build_type] = build_result
43
+ end
44
+ end
45
+
46
+ result_message = results.each_pair.map do |(result_type, result_status)|
47
+ type = "- \e[1;33m#{result_type}\e[0m\t=> "
48
+ desc = result_status.zero? ? "\e[32msuccess\e[0m" : "\e[31mfail\e[0m"
49
+
50
+ "#{type} #{desc}"
51
+ end.join("\n")
52
+
53
+ if results.values.all?(&:zero?)
54
+ puts "[\e[32mARMITAGE_RUBOCOP BUILD\e[0m] => \e[1;33mSuccessful!\e[0m\n#{result_message}"
55
+ else
56
+ abort "[\e[31mARMITAGE_RUBOCOP BUILD\e[0m] => FAILED!\n#{result_message}"
57
+ end
58
+ end
59
+
60
+ namespace :validation do
61
+ desc 'Checks that all *.yml files has the valid structure'
62
+ task :valid_yamls do
63
+ yamls = Dir[Pathname.new(__FILE__).join('../lib/**/*.yml')]
64
+
65
+ # NOTE: try to load without Psych exceptions
66
+ invalid_yamls = yamls.each_with_object([]) do |file_name, invalid_files|
67
+ YAML.safe_load(File.read(file_name)) rescue (invalid_files << "- \e[33m#{file_name}\e[0m")
68
+ end
69
+
70
+ if invalid_yamls.empty?
71
+ puts "[\e[32mYAML FILE VALIDATION\e[0m] => \e[1;33mall files has valid strucutre!\e[0m"
72
+ else
73
+ invalid_yamls_message = invalid_yamls.join("\n")
74
+ abort "[\e[31mYAML FILE VALIDATION\e[0m] => some files has invalid structure:\n" \
75
+ "#{invalid_yamls_message}"
76
+ end
77
+ end
78
+
79
+ desc 'Checks that all defined cops can be used'
80
+ task :recognizable_cops do
81
+ yamls = Dir[Pathname.new(__FILE__).join('../lib/**/*.yml')]
82
+ invalid_cops = Hash.new { |h, k| h[k] = +'' }
83
+
84
+ # NOTE: strongly rubocop-related realization
85
+ # - see https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/config.rb
86
+ # - see https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/config_loader.rb
87
+ # - RuboCop::Config#validate
88
+ # - RuboCop::Config#warn_about_unrecognized_cops
89
+ # - RuboCop::ConfigLoader.load_file
90
+ # - RuboCop::ConfigLoader.default_configuration
91
+ yamls.each do |yaml_file|
92
+ rubocop_config = RuboCop::ConfigLoader.load_file(yaml_file)
93
+
94
+ # NOTE: validate cop existence
95
+ rubocop_config.each_key do |cop|
96
+ next if RuboCop::ConfigLoader.default_configuration.key?(cop)
97
+ next if RuboCop::Cop::Cop.registry.contains_cop_matching?([cop])
98
+ next if cop == 'inherit_mode'
99
+
100
+ invalid_cops[cop] = "\e[31mBAD COP\e[0m"
101
+ end
102
+
103
+ # NOTE: validate cop params
104
+ rubocop_config.each_key do |cop|
105
+ next if invalid_cops.key?(cop)
106
+
107
+ invalid_params = Set.new
108
+
109
+ rubocop_config[cop].each_key do |cop_param|
110
+ next if RuboCop::ConfigValidator::COMMON_PARAMS.include?(cop_param)
111
+ next if NON_CHECKABLE_COPS.include?(cop)
112
+ next if RuboCop::ConfigLoader.default_configuration[cop].key?(cop_param)
113
+
114
+ invalid_params << "\e[35m#{cop_param}\e[0m"
115
+ end
116
+
117
+ next if invalid_params.empty?
118
+
119
+ invalid_cops[cop] = "\e[31mBAD PARAMS\e[0m: #{invalid_params.to_a.join(', ')}"
120
+ end
121
+ end
122
+
123
+ if invalid_cops.empty?
124
+ puts "[\e[32mCOP RECOGNITION CHECK\e[0m] => \e[1;33mall cops are recognizable!\e[0m"
125
+ else
126
+ invalid_cops_message = invalid_cops.each_pair.map do |cop, message|
127
+ "[\e[32m#{cop}\e[0m]\t- #{message}"
128
+ end.join("\n")
129
+
130
+ abort "[\e[31mCOP RECOGNITION CHECK\e[0m] => some cops can not be fully recognized:\n" \
131
+ "#{invalid_cops_message}"
132
+ end
133
+ end
134
+ end
135
+ end
136
+ # rubocop:enable Rails/RakeEnvironment
137
+
138
+ task default: :rubocop
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.version = '0.85.1'
8
+
9
+ spec.name = 'armitage-rubocop'
10
+ spec.license = 'MIT'
11
+ spec.authors = ['Rustam Ibragimov']
12
+ spec.email = ['iamdaiver@icloud.com']
13
+ spec.homepage = 'https://github.com/0exp/armitage'
14
+
15
+ spec.summary = 'A set of rubocop settings'
16
+ spec.description = 'A set of rubocop settings used in my own projects.' \
17
+ 'Support for: vanilla ruby, rspec, rails.'
18
+
19
+ spec.bindir = 'bin'
20
+ spec.require_paths = ['lib']
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+
25
+ spec.add_dependency 'rubocop', '= 0.85.1'
26
+ spec.add_dependency 'rubocop-performance', '= 1.6.1'
27
+ spec.add_dependency 'rubocop-rails', '= 2.6.0'
28
+ spec.add_dependency 'rubocop-rspec', '= 1.40.0'
29
+ spec.add_dependency 'rubocop-rake', '= 0.5.1'
30
+
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'rake'
33
+ spec.add_development_dependency 'pry'
34
+ end