boxt_ruby_style_guide 8.5.1 → 9.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b1063f1ad100f533865999a851ee2af7970193805e6d98aed67fcc19d738817
4
- data.tar.gz: dbe3898f75c24f22544dbc4f012e06ab9adb80620f12f3d33c54153a7eec29c6
3
+ metadata.gz: 0b6c99e3e3fb5828e9b5dbec10c8612d6b0841f019685367c345ac78928a0f82
4
+ data.tar.gz: f08f3542b536055ac7b95d855f0e3a8a58d17d1ecda6cf329c37b4aed8b61c02
5
5
  SHA512:
6
- metadata.gz: 59a972205dba30e8f5653ffabbc7d6ef2abcec0bc186c35e5e5abc9469a314de3cc2e41cf726b0d3a72f9012fed6a440cdd2b86d700d91a7123da6be20fdfa04
7
- data.tar.gz: b7b630ec7251fe98990b537c522371c2d1c8a8442ba103742febe607cf295396cbe00e2ec34cfd190cc298729756312c24342040e5d397d169a6d1dc41703356
6
+ metadata.gz: 2dd53905fed000e8821df54c25d377b9dec190b84924ad4086bacd5aee3b200b5a39e0080bdea489866acbe4268ac910c6e72594f7040b86babd1cc70feb44d8
7
+ data.tar.gz: 5e375c601ebeb517be15c383c472008b31753bfa89bbad63971c92afc5b25f2db96bf296e0fbda73977c7e9b33a4de20e755c4fc9efb07ac2c4d409b9122fdfc
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # BOXT Ruby Style Guide
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/boxt_ruby_style_guide.png)](https://badge.fury.io/rb/boxt_ruby_style_guide)
3
+ [![Gem Version](https://badge.fury.io/rb/boxt_ruby_style_guide.svg)](https://badge.fury.io/rb/boxt_ruby_style_guide)
4
+ [![CI](https://github.com/boxt/boxt_ruby_style_guide/actions/workflows/ci.yml/badge.svg)](https://github.com/boxt/boxt_ruby_style_guide/actions/workflows/ci.yml)
4
5
 
5
6
  Ruby style guide and base Rubocop settings for Boxt Ruby projects.
6
7
 
@@ -23,6 +24,10 @@ And then execute:
23
24
  bundle
24
25
  ```
25
26
 
27
+ ## Requirements
28
+
29
+ * Ruby 2.7 or above
30
+
26
31
  ## Usage
27
32
 
28
33
  Add a `.rubocop.yml` file to the root of your project with the following settings:
@@ -38,6 +43,7 @@ inherit_gem:
38
43
  ### NewCops
39
44
 
40
45
  `NewCops` is enabled by default.
46
+
41
47
  ### Additional Extensions/Cops
42
48
 
43
49
  The following Rubocop gems are also installed with this gem:
@@ -61,26 +67,6 @@ require:
61
67
  - rubocop-rspec # if your project is using rspec then add this, plus the - rspec.yml setting above
62
68
  ```
63
69
 
64
- ## Lint Tasks
65
-
66
- Lint tasks to run against files listed as changed by Git.
67
-
68
- To run `rubocop` against any changed files use:
69
-
70
- ```sh
71
- RUBOCOP_LINT_BASE=your-base-branch rake lint:rubocop
72
- ```
73
-
74
- To run `rubocop` with autofix, use one of the following:
75
-
76
- ```sh
77
- RUBOCOP_LINT_BASE=your-base-branch rake lint:rubocop -a
78
- RUBOCOP_LINT_BASE=your-base-branch rake lint:rubocop -A
79
- ```
80
-
81
-
82
- If there are no changed files the commands will run against all files.
83
-
84
70
  ## Editor Plugins
85
71
 
86
72
  There are also some useful Rubocop editor plugins to help with in-editor linting.
data/Rakefile CHANGED
@@ -4,8 +4,6 @@ require "bundler/gem_tasks"
4
4
  require "rake/testtask"
5
5
  require "rspec/core/rake_task"
6
6
 
7
- import "lib/tasks/lint.rake"
8
-
9
7
  RSpec::Core::RakeTask.new(:spec) do |t|
10
8
  t.pattern = Dir.glob("spec/**/*_spec.rb")
11
9
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 8.5.1
1
+ 9.0.2
data/default.yml CHANGED
@@ -6,10 +6,10 @@ AllCops:
6
6
  - tmp/**/*
7
7
  - vendor/**/*
8
8
  NewCops: enable
9
- TargetRubyVersion: 2.7
10
9
  Layout/LineLength:
11
10
  Exclude:
12
11
  - config/routes.rb
12
+ - config/routes/*
13
13
  Max: 120
14
14
  Metrics/AbcSize:
15
15
  Exclude:
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "boxt_ruby_style_guide/railtie" if defined?(Rails)
4
3
  require "boxt_ruby_style_guide/version"
5
4
 
6
5
  module BoxtRubyStyleGuide
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxt_ruby_style_guide
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.5.1
4
+ version: 9.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boxt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-08 00:00:00.000000000 Z
11
+ date: 2022-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: git
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.4'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rubocop
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - '='
32
18
  - !ruby/object:Gem::Version
33
- version: 1.22.3
19
+ version: 1.24.1
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - '='
39
25
  - !ruby/object:Gem::Version
40
- version: 1.22.3
26
+ version: 1.24.1
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rubocop-faker
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +44,14 @@ dependencies:
58
44
  requirements:
59
45
  - - '='
60
46
  - !ruby/object:Gem::Version
61
- version: 2.12.4
47
+ version: 2.13.0
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - '='
67
53
  - !ruby/object:Gem::Version
68
- version: 2.12.4
54
+ version: 2.13.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rubocop-rake
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,16 +72,16 @@ dependencies:
86
72
  requirements:
87
73
  - - '='
88
74
  - !ruby/object:Gem::Version
89
- version: 2.6.0
75
+ version: 2.7.0
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - '='
95
81
  - !ruby/object:Gem::Version
96
- version: 2.6.0
97
- description: Ruby styleguide info for the BOXT projects, as well as config settings
98
- for Rubocop
82
+ version: 2.7.0
83
+ description: Ruby style guide info for BOXT projects, as well as config settings for
84
+ Rubocop
99
85
  email:
100
86
  - developers@boxt.co.uk
101
87
  executables: []
@@ -108,17 +94,14 @@ files:
108
94
  - VERSION
109
95
  - default.yml
110
96
  - lib/boxt_ruby_style_guide.rb
111
- - lib/boxt_ruby_style_guide/filepath_matcher.rb
112
- - lib/boxt_ruby_style_guide/git_diff.rb
113
- - lib/boxt_ruby_style_guide/railtie.rb
114
97
  - lib/boxt_ruby_style_guide/version.rb
115
- - lib/tasks/lint.rake
116
98
  - rails.yml
117
99
  - rspec.yml
118
100
  homepage: https://github.com/boxt/ruby-style-guide
119
101
  licenses:
120
102
  - MIT
121
- metadata: {}
103
+ metadata:
104
+ rubygems_mfa_required: 'true'
122
105
  post_install_message:
123
106
  rdoc_options: []
124
107
  require_paths:
@@ -137,5 +120,5 @@ requirements: []
137
120
  rubygems_version: 3.2.22
138
121
  signing_key:
139
122
  specification_version: 4
140
- summary: Ruby styleguide info for the BOXT Ruby projects
123
+ summary: Ruby style guide info for BOXT Ruby projects
141
124
  test_files: []
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BoxtRubyStyleGuide
4
- ##
5
- # Sanitizes a list of filepaths based on Rubocops exclusions
6
- class FilepathMatcher
7
- require "yaml"
8
-
9
- ##
10
- # Compare a given filepath with a grep-style filename pattern
11
- FILEPATH_PATTERN_MATCH = proc do |filepath, pattern|
12
- File.fnmatch(pattern, filepath, File::FNM_PATHNAME)
13
- end
14
-
15
- ##
16
- # Array of file patterns to make sure we only check files that are Ruby files
17
- INCLUDE_PATTERNS = %w[
18
- Gemfile
19
- Rakefile
20
- *.gemspec
21
- **/*.rb
22
- **/*.rake
23
- ].freeze
24
-
25
- ##
26
- # Array of the excluded files from Rubocop default.yml config
27
- EXCLUDE_PATTERNS = YAML.load_file(
28
- BoxtRubyStyleGuide.root.join("default.yml")
29
- ).dig("AllCops", "Exclude")
30
-
31
- attr_reader :filepaths
32
-
33
- def initialize(*filepaths)
34
- @filepaths = filepaths
35
- end
36
-
37
- def all_matches
38
- filepaths.select do |filepath|
39
- filepath_proc = FILEPATH_PATTERN_MATCH.curry.call(filepath)
40
- INCLUDE_PATTERNS.any?(filepath_proc) && EXCLUDE_PATTERNS.none?(filepath_proc)
41
- end
42
- end
43
- end
44
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BoxtRubyStyleGuide
4
- # Returns a list of files that have changed, as detected by `git-diff`
5
- #
6
- # TODO: Write tests for this to ensure we're pulling the desired diff files
7
- # see: https://github.com/ruby-git/ruby-git
8
- class GitDiff
9
- require "git"
10
-
11
- ##
12
- # List of Git statuses we should test
13
- # See: https://git-scm.com/docs/git-status#_short_format
14
- TEST_STATUSES = %w[M A U].freeze
15
-
16
- attr_reader :base
17
-
18
- def initialize(base:)
19
- @base = base
20
- end
21
-
22
- ##
23
- # A list of the local file paths of Ruby files with committed changes.
24
- #
25
- # Returns Array
26
- def all
27
- @all ||= git.diff(base).name_status.select { |_, stat| TEST_STATUSES.include?(stat) }.keys
28
- end
29
-
30
- private
31
-
32
- def git
33
- @git ||= Git.open(".")
34
- end
35
- end
36
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails"
4
-
5
- module BoxtRubyStyleGuide
6
- class Railtie < Rails::Railtie
7
- rake_tasks do
8
- files = BoxtRubyStyleGuide.root.join("lib", "tasks", "*.rake")
9
- Dir[files].each { |file| load(file) }
10
- end
11
- end
12
- end
data/lib/tasks/lint.rake DELETED
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "boxt_ruby_style_guide"
4
- require "boxt_ruby_style_guide/filepath_matcher"
5
- require "boxt_ruby_style_guide/git_diff"
6
- require "rubocop"
7
-
8
- namespace :lint do
9
- desc "Runs rubocop against all files with committed changes different from base branch"
10
- task :rubocop do
11
- file_paths = sanitized_file_paths
12
- puts "File paths: #{file_paths.join(', ')}"
13
-
14
- if file_paths.any?
15
- auto_flag_opt = ARGV.select { |a| ["-a", "-A"].include?(a) }.first
16
- exec("bundle exec rubocop #{file_paths.join(' ')} #{auto_flag_opt}".strip)
17
- else
18
- puts "No Ruby files changed"
19
- end
20
- end
21
- end
22
-
23
- private
24
-
25
- # Returns an array of files
26
- def sanitized_file_paths
27
- base = ENV.fetch("RUBOCOP_LINT_BASE", "main")
28
- changed_files = BoxtRubyStyleGuide::GitDiff.new(base: base).all
29
- BoxtRubyStyleGuide::FilepathMatcher.new(*changed_files).all_matches
30
- end