pronto-foodcritic 0.10.0 → 0.11.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: c6e5598d30e1988f2b14ce5d02cbab0f0a410a8762821dfdf6536735a44429d2
4
- data.tar.gz: d3daaa8307ba8e71bfa61be8444992f670c231c92926f1fbcbe13f6990111adc
3
+ metadata.gz: 705d781bf92a42d5435cfd6b81ba1c7e6a1a84cdab215388ce65d18554a1c213
4
+ data.tar.gz: 4352eb684c8a4f778334f3bce543df239319f126a53d6254b69939ee73ef2afc
5
5
  SHA512:
6
- metadata.gz: f871a8dcf599975811b344b2d4effe1e4ed1ee9e4c31f31974b51d8699de3bb05b5dc93879147f833db7ad54b7a60b61d20909c56cf865b5e5e89bda3aea3af9
7
- data.tar.gz: 132e9c8861597cbf7b778d455b351df2bb37e8ea37d56943c2c1395f2e1d81166ab21c917023196db87e21381851483fd9d1b58798c4852dd0b855a039d39629
6
+ metadata.gz: 5167e5cbca5bc798efb4f472b3f43a435bd1272edfeb1cc19d04065f2872e2afb83d46e097c79d569ebc09295eea059195a6c626618a24f9d60ae2e858fac99a
7
+ data.tar.gz: a635b03ed8878b0ebf828e7a27e7039563f5a6b380782bcc958a40b8235d969c72977b113c39bf9f4bf88ec33de8887157be62d06641c5de266f2614b60112a1
@@ -0,0 +1,3 @@
1
+ # Order is important. The last matching pattern takes the most precedence.
2
+ # Default owners for everything in the repo.
3
+ * @prontolabs/core
@@ -0,0 +1,22 @@
1
+ name: Checks
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ ruby:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0']
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
21
+ - name: rake spec
22
+ run: bundle exec rake spec
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## 0.11.0
5
+
6
+ ### Changes
7
+
8
+ * Add Foodcritic options rule_file, search_gems and include_rules, allows to customize CI with custom ignores and Foodcritic rules.
9
+ * Add exclude option to ignore Foodcritic linter.
10
+
3
11
  ## 0.2.2
4
12
 
5
13
  ### Bugs fixed
data/README.md CHANGED
@@ -7,6 +7,27 @@
7
7
 
8
8
  Pronto runner for [Food Critic](https://github.com/acrmp/foodcritic), lint tool for chef. [What is Pronto?](https://github.com/mmozuras/pronto)
9
9
 
10
+ ## Configuration
11
+
12
+ You can provide several Food Critic options via `.pronto.yml`:
13
+
14
+ ```yml
15
+ foodcritic:
16
+ # Like CLI option --search-gems
17
+ search_gems: true
18
+
19
+ # Like CLI option --include, add custom rules to your CI
20
+ include_rules:
21
+ - lib/foodcritic/rules
22
+
23
+ # Like CLI option --rule-file
24
+ rule_file: .foodcritic-ci
25
+
26
+ # File GLOBs to ignore, matching files won't be passed to Food Critic
27
+ exclude:
28
+ - '**/test/integration/**/*_spec.rb'
29
+ ```
30
+
10
31
  ## Note
11
32
 
12
33
  Currently, naively uses path to determine if a file is a cookbook or a role configuration.
@@ -7,7 +7,7 @@ module Pronto
7
7
  return [] if paths[:cookbook_paths].none? && paths[:role_paths].none?
8
8
 
9
9
  @linter = ::FoodCritic::Linter.new
10
- @linter.check(paths).warnings.flat_map do |warning|
10
+ @linter.check(options).warnings.flat_map do |warning|
11
11
  ruby_patches.select { |patch| patch.new_file_full_path.to_s == warning.match[:filename] }
12
12
  .flat_map(&:added_lines)
13
13
  .select { |line| line.new_lineno == warning.match[:line] }
@@ -15,11 +15,22 @@ module Pronto
15
15
  end
16
16
  end
17
17
 
18
+ def options
19
+ @options ||= begin
20
+ result = {}.merge(paths)
21
+ result[:rule_file] = foodcritic_rule_file if foodcritic_rule_file
22
+ result[:search_gems] = foodcritic_search_gems if foodcritic_search_gems
23
+ result[:include_rules] = Array(foodcritic_include_rules)
24
+ result
25
+ end
26
+ end
27
+
18
28
  def paths
19
29
  @paths ||= begin
20
30
  result = { cookbook_paths: [], role_paths: [] }
21
31
  ruby_patches.each do |patch|
22
32
  path = patch.new_file_full_path.to_s
33
+ next if foodcritic_exclude.any? { |r| File.fnmatch(r, path) }
23
34
  if path.include?('cookbook')
24
35
  result[:cookbook_paths] << path
25
36
  elsif path.include?('role')
@@ -35,5 +46,26 @@ module Pronto
35
46
  message = "#{warning.rule.code} - #{warning.rule.name}"
36
47
  Message.new(path, line, :warning, message, nil, self.class)
37
48
  end
49
+
50
+ def pronto_foodcritic_config
51
+ @pronto_foodcritic_config ||= Pronto::ConfigFile.new.to_h['foodcritic'] || {}
52
+ end
53
+
54
+ def foodcritic_search_gems
55
+ pronto_foodcritic_config.fetch('search_gems', nil)
56
+ end
57
+
58
+ def foodcritic_rule_file
59
+ pronto_foodcritic_config.fetch('rule_file', nil)
60
+ end
61
+
62
+ def foodcritic_include_rules
63
+ pronto_foodcritic_config.fetch('include_rules', [])
64
+ end
65
+
66
+ def foodcritic_exclude
67
+ Array(pronto_foodcritic_config.fetch('exclude', []))
68
+ end
69
+
38
70
  end
39
71
  end
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module FoodCriticVersion
3
- VERSION = '0.10.0'.freeze
3
+ VERSION = '0.11.0'.freeze
4
4
  end
5
5
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
33
33
  s.require_paths = ['lib']
34
34
 
35
35
  s.add_dependency('foodcritic', '~> 15', '>= 10.0.0')
36
- s.add_dependency('pronto', '~> 0.10.0')
36
+ s.add_dependency('pronto', '~> 0.11.0')
37
37
  s.add_development_dependency('rake', '~> 12.0')
38
38
  s.add_development_dependency('rspec', '~> 3.4')
39
39
  s.add_development_dependency('rspec-its', '~> 1.2')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-foodcritic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-03 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foodcritic
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.10.0
39
+ version: 0.11.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.10.0
46
+ version: 0.11.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,8 @@ extra_rdoc_files:
94
94
  - LICENSE
95
95
  - README.md
96
96
  files:
97
+ - ".github/CODEOWNERS"
98
+ - ".github/workflows/checks.yml"
97
99
  - CHANGELOG.md
98
100
  - CONTRIBUTING.md
99
101
  - LICENSE
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  requirements: []
123
- rubygems_version: 3.0.1
125
+ rubygems_version: 3.0.3
124
126
  signing_key:
125
127
  specification_version: 4
126
128
  summary: Pronto runner for Food Critic, lint tool for chef