foodcritic 16.2.0 → 16.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/foodcritic.gemspec +2 -2
- data/lib/foodcritic.rb +2 -1
- data/lib/foodcritic/command_line.rb +22 -2
- data/lib/foodcritic/domain.rb +2 -4
- data/lib/foodcritic/gerkin/tag.rb +55 -0
- data/lib/foodcritic/gerkin/tag_expression.rb +66 -0
- data/lib/foodcritic/rules/fc123.rb +3 -5
- data/lib/foodcritic/version.rb +1 -1
- metadata +31 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2122adab9b427f5729d3be4d5ebd1a3eefe6e6f23e013433885752286ccd8d2b
|
4
|
+
data.tar.gz: 36ddd91e875713be1ce6f4c99965b943e2d5c9f590ca62e11ce972dd6ad73b7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4fb33c61d62ebdab3843fb9918e26b94b65316b109d79458ed38be148f6c20084e0b657f57197414845bbd1f5371e9c59b6635100e9e2d90a29d05e7fe31ce2
|
7
|
+
data.tar.gz: a27169770e288482837b07e80f292a8882347df9f6587bd426ec03436bf43d69080f28942e4372cc3246a67cec728ba65770efba92e4929312cdf54c91974f55
|
data/Gemfile
CHANGED
data/foodcritic.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "foodcritic/version"
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "foodcritic"
|
6
6
|
s.version = FoodCritic::VERSION
|
7
|
-
s.description = "
|
7
|
+
s.description = "A code linting tool for Chef Infra cookbooks."
|
8
8
|
s.summary = "foodcritic-#{s.version}"
|
9
9
|
s.authors = ["Andrew Crump"]
|
10
10
|
s.homepage = "http://foodcritic.io"
|
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
Dir["misc/**/*"]
|
18
18
|
s.files += Dir["Gemfile", "foodcritic.gemspec", "LICENSE"]
|
19
19
|
|
20
|
-
s.add_dependency("cucumber-core", ">= 1.3", "< 4.0")
|
21
20
|
s.add_dependency("nokogiri", ">= 1.5", "< 2.0")
|
22
21
|
s.add_dependency("rake")
|
23
22
|
s.add_dependency("treetop", "~> 1.4")
|
@@ -25,6 +24,7 @@ Gem::Specification.new do |s|
|
|
25
24
|
s.add_dependency("erubis")
|
26
25
|
s.add_dependency("rufus-lru", "~> 1.0")
|
27
26
|
|
27
|
+
s.add_development_dependency "cucumber-core", ">= 1.3", "< 4.0"
|
28
28
|
s.add_development_dependency "rspec", "~> 3.5"
|
29
29
|
s.add_development_dependency "fuubar", "~> 2.0"
|
30
30
|
s.add_development_dependency "rspec-command", "~> 1.0"
|
data/lib/foodcritic.rb
CHANGED
@@ -2,7 +2,6 @@ Encoding.default_external = Encoding::UTF_8
|
|
2
2
|
Encoding.default_internal = Encoding::UTF_8
|
3
3
|
|
4
4
|
require "pathname"
|
5
|
-
require "cucumber/core"
|
6
5
|
require "treetop"
|
7
6
|
require "ripper"
|
8
7
|
require "ffi_yajl"
|
@@ -22,3 +21,5 @@ require_relative "foodcritic/output"
|
|
22
21
|
require_relative "foodcritic/rake_task"
|
23
22
|
require_relative "foodcritic/template"
|
24
23
|
require_relative "foodcritic/version"
|
24
|
+
require_relative "foodcritic/gerkin/tag"
|
25
|
+
require_relative "foodcritic/gerkin/tag_expression"
|
@@ -111,6 +111,26 @@ module FoodCritic
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
# The end of life message.
|
115
|
+
#
|
116
|
+
# @return [String] A text to warn end users about foodcritic's end of life
|
117
|
+
def show_end_of_life_msg
|
118
|
+
"
|
119
|
+
*******************************************************************************
|
120
|
+
WARNING: Foodcritic will be end of life in April 2020
|
121
|
+
*******************************************************************************
|
122
|
+
Please use Cookstyle to ensure all of your Chef Infra code meets the latest
|
123
|
+
best practices.
|
124
|
+
|
125
|
+
Cookstyle is a code linting tool that helps you to write better Chef Infra
|
126
|
+
Cookbooks by detecting and automatically correct cookbook code.
|
127
|
+
|
128
|
+
For more information, use the command:
|
129
|
+
|
130
|
+
cookstyle -h
|
131
|
+
"
|
132
|
+
end
|
133
|
+
|
114
134
|
# Show the command help to the end user?
|
115
135
|
#
|
116
136
|
# @return [Boolean] True if help should be shown.
|
@@ -118,11 +138,11 @@ module FoodCritic
|
|
118
138
|
@args.length == 1 && @args.first == "--help"
|
119
139
|
end
|
120
140
|
|
121
|
-
# The help text.
|
141
|
+
# The help text plus the end of life message.
|
122
142
|
#
|
123
143
|
# @return [String] Help text describing the command-line options available.
|
124
144
|
def help
|
125
|
-
@parser.help
|
145
|
+
@parser.help + show_end_of_life_msg
|
126
146
|
end
|
127
147
|
|
128
148
|
# Show the current version to the end user?
|
data/lib/foodcritic/domain.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "cucumber/core/gherkin/tag_expression"
|
2
|
-
|
3
1
|
module FoodCritic
|
4
2
|
# A warning of a possible issue
|
5
3
|
class Warning
|
@@ -95,8 +93,8 @@ module FoodCritic
|
|
95
93
|
|
96
94
|
# Checks the rule tags to see if they match a Gherkin (Cucumber) expression
|
97
95
|
def matches_tags?(tag_expr)
|
98
|
-
|
99
|
-
tags.map { |tag|
|
96
|
+
::Foodcritic::Gherkin::TagExpression.new(tag_expr).evaluate(
|
97
|
+
tags.map { |tag| ::Foodcritic::Gherkin::Tag.new(nil, tag) }
|
100
98
|
)
|
101
99
|
end
|
102
100
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# this is vendored from cucumber-core gem with the module/class names changed
|
2
|
+
|
3
|
+
module Foodcritic
|
4
|
+
module Gherkin
|
5
|
+
class Tag
|
6
|
+
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
def initialize(location, name)
|
10
|
+
@location = location
|
11
|
+
@name = name
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect
|
15
|
+
%{#<#{self.class} "#{name}" (#{location})>}
|
16
|
+
end
|
17
|
+
|
18
|
+
def file_colon_line
|
19
|
+
location.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def file
|
23
|
+
location.file
|
24
|
+
end
|
25
|
+
|
26
|
+
def line
|
27
|
+
location.line
|
28
|
+
end
|
29
|
+
|
30
|
+
def location
|
31
|
+
raise('Please set @location in the constructor') unless defined?(@location)
|
32
|
+
@location
|
33
|
+
end
|
34
|
+
|
35
|
+
def attributes
|
36
|
+
[tags, comments, multiline_arg].flatten
|
37
|
+
end
|
38
|
+
|
39
|
+
def tags
|
40
|
+
# will be overriden by nodes that actually have tags
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
|
44
|
+
def comments
|
45
|
+
# will be overriden by nodes that actually have comments
|
46
|
+
[]
|
47
|
+
end
|
48
|
+
|
49
|
+
def multiline_arg
|
50
|
+
# will be overriden by nodes that actually have a multiline_argument
|
51
|
+
Test::EmptyMultilineArgument.new
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# this is vendored from cucumber-core gem with the module/class names changed
|
2
|
+
# in the 4.0 release of cucumber-core they removed support for legacy tags (~FC100)
|
3
|
+
# and we're not going to force everyone to redo their tags on a EOL product
|
4
|
+
|
5
|
+
module Foodcritic
|
6
|
+
module Gherkin
|
7
|
+
class TagExpression
|
8
|
+
|
9
|
+
attr_reader :limits
|
10
|
+
|
11
|
+
def initialize(tag_expressions)
|
12
|
+
@ands = []
|
13
|
+
@limits = {}
|
14
|
+
tag_expressions.each do |expr|
|
15
|
+
add(expr.strip.split(/\s*,\s*/))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def empty?
|
20
|
+
@ands.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
def evaluate(tags)
|
24
|
+
return true if @ands.flatten.empty?
|
25
|
+
vars = Hash[*tags.map{|tag| [tag.name, true]}.flatten]
|
26
|
+
raise "No vars" if vars.nil? # Useless statement to prevent ruby warnings about unused var
|
27
|
+
!!Kernel.eval(ruby_expression)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def add(tags_with_negation_and_limits)
|
33
|
+
negatives, positives = tags_with_negation_and_limits.partition{|tag| tag =~ /^~/}
|
34
|
+
@ands << (store_and_extract_limits(negatives, true) + store_and_extract_limits(positives, false))
|
35
|
+
end
|
36
|
+
|
37
|
+
def store_and_extract_limits(tags_with_negation_and_limits, negated)
|
38
|
+
tags_with_negation = []
|
39
|
+
tags_with_negation_and_limits.each do |tag_with_negation_and_limit|
|
40
|
+
tag_with_negation, limit = tag_with_negation_and_limit.split(':')
|
41
|
+
tags_with_negation << tag_with_negation
|
42
|
+
if limit
|
43
|
+
tag_without_negation = negated ? tag_with_negation[1..-1] : tag_with_negation
|
44
|
+
if @limits[tag_without_negation] && @limits[tag_without_negation] != limit.to_i
|
45
|
+
raise "Inconsistent tag limits for #{tag_without_negation}: #{@limits[tag_without_negation]} and #{limit.to_i}"
|
46
|
+
end
|
47
|
+
@limits[tag_without_negation] = limit.to_i
|
48
|
+
end
|
49
|
+
end
|
50
|
+
tags_with_negation
|
51
|
+
end
|
52
|
+
|
53
|
+
def ruby_expression
|
54
|
+
"(" + @ands.map do |ors|
|
55
|
+
ors.map do |tag|
|
56
|
+
if tag =~ /^~(.*)/
|
57
|
+
"!vars['#{$1}']"
|
58
|
+
else
|
59
|
+
"vars['#{tag}']"
|
60
|
+
end
|
61
|
+
end.join("||")
|
62
|
+
end.join(")&&(") + ")"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -4,12 +4,10 @@ rule "FC123", "Content of a cookbook file is larger than 1MB" do
|
|
4
4
|
values = []
|
5
5
|
files_path = File.join(path, "files")
|
6
6
|
if File.exist?(files_path)
|
7
|
-
Dir.
|
8
|
-
|
9
|
-
|
10
|
-
size = File.size(File.join(files_path, file))
|
7
|
+
Dir.glob("#{files_path}/**/*").each do |file|
|
8
|
+
size = File.size(file)
|
11
9
|
if size > 1024 * 1024 # 1 megabyte
|
12
|
-
values += [file_match(
|
10
|
+
values += [file_match(file)]
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
data/lib/foodcritic/version.rb
CHANGED
metadata
CHANGED
@@ -1,35 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foodcritic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 16.
|
4
|
+
version: 16.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Crump
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: cucumber-core
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '4.0'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.3'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '4.0'
|
33
13
|
- !ruby/object:Gem::Dependency
|
34
14
|
name: nokogiri
|
35
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +100,26 @@ dependencies:
|
|
120
100
|
- - "~>"
|
121
101
|
- !ruby/object:Gem::Version
|
122
102
|
version: '1.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: cucumber-core
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.3'
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '4.0'
|
113
|
+
type: :development
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1.3'
|
120
|
+
- - "<"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '4.0'
|
123
123
|
- !ruby/object:Gem::Dependency
|
124
124
|
name: rspec
|
125
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,8 +162,8 @@ dependencies:
|
|
162
162
|
- - "~>"
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: '1.0'
|
165
|
-
description:
|
166
|
-
email:
|
165
|
+
description: A code linting tool for Chef Infra cookbooks.
|
166
|
+
email:
|
167
167
|
executables:
|
168
168
|
- foodcritic
|
169
169
|
extensions: []
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- lib/foodcritic/domain.rb
|
184
184
|
- lib/foodcritic/dsl.rb
|
185
185
|
- lib/foodcritic/error_checker.rb
|
186
|
+
- lib/foodcritic/gerkin/tag.rb
|
187
|
+
- lib/foodcritic/gerkin/tag_expression.rb
|
186
188
|
- lib/foodcritic/linter.rb
|
187
189
|
- lib/foodcritic/notifications.rb
|
188
190
|
- lib/foodcritic/output.rb
|
@@ -307,7 +309,7 @@ homepage: http://foodcritic.io
|
|
307
309
|
licenses:
|
308
310
|
- MIT
|
309
311
|
metadata: {}
|
310
|
-
post_install_message:
|
312
|
+
post_install_message:
|
311
313
|
rdoc_options: []
|
312
314
|
require_paths:
|
313
315
|
- lib
|
@@ -322,8 +324,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
322
324
|
- !ruby/object:Gem::Version
|
323
325
|
version: '0'
|
324
326
|
requirements: []
|
325
|
-
rubygems_version: 3.
|
326
|
-
signing_key:
|
327
|
+
rubygems_version: 3.1.2
|
328
|
+
signing_key:
|
327
329
|
specification_version: 4
|
328
|
-
summary: foodcritic-16.
|
330
|
+
summary: foodcritic-16.3.0
|
329
331
|
test_files: []
|