boxt_ruby_style_guide 8.6.0 → 9.0.0

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: b848d450aca559043327a5023b63c46ab860192f81bb522731c52430e54d0ba3
4
- data.tar.gz: 8124ee02a9e37c20d88c8219eef01a16edde84bee60c7c44e50f82a7c904127a
3
+ metadata.gz: c0320ff4048146db59fa7bbef9adc08c5f473c40e99892f17373c40f907dc87e
4
+ data.tar.gz: 355eee5ed60629b1d318919b06f6033106d6790de120f2d6778025da32960ce4
5
5
  SHA512:
6
- metadata.gz: 57197bca670c43219c3cc77e71a26f10d7a7e398a24e00fdea650d58ba54a464c048a233ec7f47b0bb3d1c8a276a58f0d2cd8e7a5621be50afba5c5a783c4aa0
7
- data.tar.gz: 81fa5b4fa6fa80ac6a591d90ac85ef806775a6bd9decb64c3c9743ded14b403b9c97942c3a84a34c60efd11ba2b60c1a4ba72e2a3a4fb3add989246672ecbeac
6
+ metadata.gz: 1469474da5c6ef411da027f6818751ea46d990a5d60e9f7572f97aab9a41b1adf6ad240c701e1afd85a64b956278cfd4634ff3dd1fcb6d00af3fb6d845ddde3e
7
+ data.tar.gz: fba5a656bfa581354c59935d0fd9771adcc021898117b729b7297929846eec5dc449d0ddb2eb529abe53e5bc4697f3913e4fcc983c2daac674dce3368f438944
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 3.0.0 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.6.0
1
+ 9.0.0
data/default.yml CHANGED
@@ -6,10 +6,11 @@ AllCops:
6
6
  - tmp/**/*
7
7
  - vendor/**/*
8
8
  NewCops: enable
9
- TargetRubyVersion: 2.7
9
+ TargetRubyVersion: 3.0
10
10
  Layout/LineLength:
11
11
  Exclude:
12
12
  - config/routes.rb
13
+ - config/routes/*
13
14
  Max: 120
14
15
  Metrics/AbcSize:
15
16
  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.6.0
4
+ version: 9.0.0
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-16 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.23.0
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.23.0
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,14 +72,14 @@ 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
82
+ version: 2.7.0
97
83
  description: Ruby style guide info for BOXT projects, as well as config settings for
98
84
  Rubocop
99
85
  email:
@@ -108,11 +94,7 @@ 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
@@ -128,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
110
  requirements:
129
111
  - - ">="
130
112
  - !ruby/object:Gem::Version
131
- version: '2.7'
113
+ version: '3.0'
132
114
  required_rubygems_version: !ruby/object:Gem::Requirement
133
115
  requirements:
134
116
  - - ">="
@@ -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