boxt_ruby_style_guide 8.5.0 → 9.0.1

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: 342e1023eba740f7009c4d114b115c69288082e747a8f8035ad19e3499bcc95f
4
- data.tar.gz: 834dd2ec21c0f24318d3e406a48f1d858877cbed897b5c74e76966d92b18168c
3
+ metadata.gz: c2724f178dc6de9fbf40e9cc2ca7d4603ebae1978cf7a2aea4f2f096228a89dd
4
+ data.tar.gz: ff1f823ecf070adf49e4d4edd90fd9dd8868a8b5e681cdc1e07f2e43737e26ee
5
5
  SHA512:
6
- metadata.gz: 1e28f779654b81722f6cbcc358c0c7cf23b9dc959fb1ed8049e371c60e23e0d21a83e3175c006f3192432a4bf1e702afee9b693ff1a439d92ca86251cd2e806b
7
- data.tar.gz: bd28b61f315d1242275fe1c6eb420ea7a050942d9d04ac32e876579f4b79098e41bbd8abdb71a58f4ceea946ec2e6edc52ca39ef08ff539d092737dc42a6c0c4
6
+ metadata.gz: f6e3d7d3393d2b9d25b3e4a29b1e821ff6ede21a0e073824a3863e4e9b45b3d9a7d2c66e289dfae6371c0200b02e7bcfed0cbe73faa0892d73bd65d61d91071c
7
+ data.tar.gz: 5a90b81fbd8e19b1d29b4d61d9605b2317ec65043d7513952a45bc993c17a4f698f15af7ee8815693fd6a73fb3f1c2b68a0a34a5171e0d1e19289593b8b6ad51
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.0
1
+ 9.0.1
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:
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.0
4
+ version: 9.0.1
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-05 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.5.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.5.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