chutney 2.2.1 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +16 -0
- data/.rubocop.yml +10 -3
- data/Gemfile +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +7 -1
- data/Rakefile +8 -8
- data/chutney.gemspec +13 -6
- data/config/{chutney.yml → chutney_defaults.yml} +2 -0
- data/config/cucumber.yml +1 -0
- data/docs/index.md +1 -1
- data/docs/usage/rules.md +34 -64
- data/exe/chutney +23 -3
- data/lib/chutney.rb +18 -14
- data/lib/chutney/configuration.rb +9 -2
- data/lib/chutney/formatter.rb +6 -5
- data/lib/chutney/formatter/json_formatter.rb +2 -0
- data/lib/chutney/formatter/pie_formatter.rb +10 -13
- data/lib/chutney/formatter/rainbow_formatter.rb +13 -13
- data/lib/chutney/issue.rb +2 -0
- data/lib/chutney/linter.rb +92 -86
- data/lib/chutney/linter/avoid_full_stop.rb +4 -4
- data/lib/chutney/linter/avoid_outline_for_single_example.rb +7 -5
- data/lib/chutney/linter/avoid_scripting.rb +8 -6
- data/lib/chutney/linter/avoid_typographers_quotes.rb +16 -14
- data/lib/chutney/linter/background_does_more_than_setup.rb +8 -7
- data/lib/chutney/linter/background_requires_multiple_scenarios.rb +7 -4
- data/lib/chutney/linter/bad_scenario_name.rb +6 -4
- data/lib/chutney/linter/empty_feature_file.rb +2 -0
- data/lib/chutney/linter/file_name_differs_feature_name.rb +7 -5
- data/lib/chutney/linter/givens_after_background.rb +7 -8
- data/lib/chutney/linter/invalid_file_name.rb +3 -1
- data/lib/chutney/linter/invalid_step_flow.rb +9 -9
- data/lib/chutney/linter/missing_example_name.rb +9 -9
- data/lib/chutney/linter/missing_feature_description.rb +5 -4
- data/lib/chutney/linter/missing_feature_name.rb +5 -4
- data/lib/chutney/linter/missing_scenario_name.rb +4 -6
- data/lib/chutney/linter/missing_test_action.rb +4 -2
- data/lib/chutney/linter/missing_verification.rb +4 -2
- data/lib/chutney/linter/required_tags_starts_with.rb +7 -6
- data/lib/chutney/linter/same_tag_different_case.rb +37 -0
- data/lib/chutney/linter/same_tag_for_all_scenarios.rb +20 -19
- data/lib/chutney/linter/scenario_names_match.rb +6 -6
- data/lib/chutney/linter/tag_used_multiple_times.rb +3 -1
- data/lib/chutney/linter/too_clumsy.rb +4 -2
- data/lib/chutney/linter/too_long_step.rb +6 -4
- data/lib/chutney/linter/too_many_different_tags.rb +10 -8
- data/lib/chutney/linter/too_many_steps.rb +6 -4
- data/lib/chutney/linter/too_many_tags.rb +5 -3
- data/lib/chutney/linter/unique_scenario_names.rb +5 -5
- data/lib/chutney/linter/unknown_variable.rb +15 -15
- data/lib/chutney/linter/unused_variable.rb +15 -16
- data/lib/chutney/linter/use_background.rb +20 -19
- data/lib/chutney/linter/use_outline.rb +15 -14
- data/lib/chutney/version.rb +3 -1
- data/lib/config/locales/en.yml +3 -0
- data/spec/chutney_spec.rb +11 -9
- data/spec/spec_helper.rb +2 -0
- metadata +21 -16
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Chutney
|
2
4
|
# service class to lint for using outline
|
3
5
|
class UseOutline < Linter
|
@@ -9,18 +11,18 @@ module Chutney
|
|
9
11
|
scenarios.product(scenarios) do |lhs, rhs|
|
10
12
|
next if lhs == rhs
|
11
13
|
next if lhs[:reference][:line] > rhs[:reference][:line]
|
12
|
-
|
14
|
+
|
13
15
|
similarity = determine_similarity(lhs[:text], rhs[:text])
|
14
16
|
next unless similarity >= 0.95
|
15
|
-
|
17
|
+
|
16
18
|
similarity_pct = similarity.round(3) * 100
|
17
|
-
|
19
|
+
|
18
20
|
add_issue(lhs, rhs, similarity_pct)
|
19
21
|
end
|
20
22
|
end
|
21
|
-
|
23
|
+
|
22
24
|
def add_issue(lhs, rhs, pct)
|
23
|
-
super(I18n.t('linters.use_outline',
|
25
|
+
super(I18n.t('linters.use_outline',
|
24
26
|
pct: pct,
|
25
27
|
lhs_name: lhs[:name],
|
26
28
|
lhs_line: lhs[:reference][:line],
|
@@ -36,13 +38,12 @@ module Chutney
|
|
36
38
|
|
37
39
|
def gather_scenarios(feature)
|
38
40
|
scenarios = []
|
39
|
-
return scenarios if feature.nil? || !feature.
|
40
|
-
|
41
|
-
|
42
|
-
next unless scenario
|
43
|
-
next
|
44
|
-
|
45
|
-
|
41
|
+
return scenarios if feature.nil? || !feature.tests
|
42
|
+
|
43
|
+
scenarios do |_feature, scenario|
|
44
|
+
next unless scenario.steps
|
45
|
+
next if scenario.steps.empty?
|
46
|
+
|
46
47
|
scenarios.push generate_reference(feature, scenario)
|
47
48
|
end
|
48
49
|
scenarios
|
@@ -51,8 +52,8 @@ module Chutney
|
|
51
52
|
def generate_reference(feature, scenario)
|
52
53
|
reference = {}
|
53
54
|
reference[:reference] = location(feature, scenario, nil)
|
54
|
-
reference[:name] = "#{scenario
|
55
|
-
reference[:text] = scenario
|
55
|
+
reference[:name] = "#{scenario.keyword}: #{scenario.name}"
|
56
|
+
reference[:text] = scenario.steps.map { |step| render_step(step) }.join ' '
|
56
57
|
reference
|
57
58
|
end
|
58
59
|
end
|
data/lib/chutney/version.rb
CHANGED
data/lib/config/locales/en.yml
CHANGED
@@ -63,6 +63,9 @@ en:
|
|
63
63
|
scenario_names_match: >-
|
64
64
|
You have a scenario name which does not match the required format.
|
65
65
|
Allowed patterns are '%{pattern}'.
|
66
|
+
same_tag_different_case: >-
|
67
|
+
You have a tag which has already appeared as '@%{existing_tag}' which is a different case
|
68
|
+
to '@%{tag}'. Cucumber tags are case-sensitive: use a consistent case for your tag names.
|
66
69
|
same_tag_for_all_scenarios:
|
67
70
|
feature_level: >-
|
68
71
|
You are using the same tag (%{tag}) for all scenarios.
|
data/spec/chutney_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'chutney'
|
2
4
|
|
3
5
|
describe Chutney::ChutneyLint do
|
@@ -6,25 +8,25 @@ describe Chutney::ChutneyLint do
|
|
6
8
|
it 'has a version number' do
|
7
9
|
expect(Chutney::VERSION).not_to be nil
|
8
10
|
end
|
9
|
-
|
11
|
+
|
10
12
|
describe '#initialize' do
|
11
13
|
it 'creates an instance' do
|
12
14
|
expect(subject).not_to be_nil
|
13
15
|
end
|
14
|
-
|
16
|
+
|
15
17
|
it 'has an empty list of files if none are given' do
|
16
18
|
expect(subject.files).to eq []
|
17
19
|
end
|
18
|
-
|
20
|
+
|
19
21
|
it 'has a list of files given on initialization' do
|
20
22
|
alt_subject = Chutney::ChutneyLint.new('a', 'b')
|
21
23
|
expect(alt_subject.files).to eq %w[a b]
|
22
24
|
end
|
23
|
-
|
25
|
+
|
24
26
|
it 'initializes a results hash' do
|
25
27
|
expect(subject.results).to eq({})
|
26
28
|
end
|
27
|
-
|
29
|
+
|
28
30
|
it 'sets the load path for I18n' do
|
29
31
|
expect(I18n.load_path).not_to eq []
|
30
32
|
end
|
@@ -34,25 +36,25 @@ describe Chutney::ChutneyLint do
|
|
34
36
|
expect(subject.configuration).not_to be_nil
|
35
37
|
expect(subject.configuration).to respond_to :[]
|
36
38
|
end
|
37
|
-
|
39
|
+
|
38
40
|
it 'allows the configuration to be set explicitly' do
|
39
41
|
config = { 'BackgroundDoesMoreThanSetup' => { 'Enabled' => true } }
|
40
42
|
subject.configuration = config
|
41
43
|
expect(subject.configuration).to be config
|
42
44
|
end
|
43
|
-
|
45
|
+
|
44
46
|
it 'controls the available linters' do
|
45
47
|
subject.configuration = {}
|
46
48
|
expect(subject.linters).to be_empty
|
47
49
|
end
|
48
|
-
|
50
|
+
|
49
51
|
it 'enables linters to be activated' do
|
50
52
|
config = { 'BackgroundDoesMoreThanSetup' => { 'Enabled' => true } }
|
51
53
|
subject.configuration = config
|
52
54
|
expect(subject.linters).to eq [Chutney::BackgroundDoesMoreThanSetup]
|
53
55
|
end
|
54
56
|
end
|
55
|
-
|
57
|
+
|
56
58
|
context 'linting' do
|
57
59
|
it 'aliases analyse and analyze' do
|
58
60
|
expect(subject).to respond_to :analyse
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chutney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Brookes-Thomas
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: amatch
|
@@ -28,19 +28,19 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.4.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: cuke_modeler
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - "~>"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: '3.3'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: '3.3'
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: i18n
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,14 +103,14 @@ dependencies:
|
|
103
103
|
requirements:
|
104
104
|
- - "~>"
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
106
|
+
version: '6.0'
|
107
107
|
type: :development
|
108
108
|
prerelease: false
|
109
109
|
version_requirements: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
111
|
- - "~>"
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: '
|
113
|
+
version: '6.0'
|
114
114
|
- !ruby/object:Gem::Dependency
|
115
115
|
name: pry-byebug
|
116
116
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,14 +173,14 @@ dependencies:
|
|
173
173
|
requirements:
|
174
174
|
- - "~>"
|
175
175
|
- !ruby/object:Gem::Version
|
176
|
-
version:
|
176
|
+
version: 1.14.0
|
177
177
|
type: :development
|
178
178
|
prerelease: false
|
179
179
|
version_requirements: !ruby/object:Gem::Requirement
|
180
180
|
requirements:
|
181
181
|
- - "~>"
|
182
182
|
- !ruby/object:Gem::Version
|
183
|
-
version:
|
183
|
+
version: 1.14.0
|
184
184
|
- !ruby/object:Gem::Dependency
|
185
185
|
name: rspec
|
186
186
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,8 +195,10 @@ dependencies:
|
|
195
195
|
- - "~>"
|
196
196
|
- !ruby/object:Gem::Version
|
197
197
|
version: '3.8'
|
198
|
-
description: A linter for your Cucumber features.
|
199
|
-
|
198
|
+
description: A linter for your Cucumber features. Making sure you have nice, expressible
|
199
|
+
Gherkin is essential is making sure you have a readable test-base. Chutney is designed
|
200
|
+
to sniff out smells in your feature files. It supports any spoken language Cucumber
|
201
|
+
supports.
|
200
202
|
email:
|
201
203
|
- nigel@brookes-thomas.co.uk
|
202
204
|
executables:
|
@@ -206,6 +208,7 @@ extra_rdoc_files: []
|
|
206
208
|
files:
|
207
209
|
- ".circleci/config.yml"
|
208
210
|
- ".coveralls.yml"
|
211
|
+
- ".github/dependabot.yml"
|
209
212
|
- ".gitignore"
|
210
213
|
- ".rspec"
|
211
214
|
- ".rubocop.yml"
|
@@ -215,7 +218,8 @@ files:
|
|
215
218
|
- README.md
|
216
219
|
- Rakefile
|
217
220
|
- chutney.gemspec
|
218
|
-
- config/
|
221
|
+
- config/chutney_defaults.yml
|
222
|
+
- config/cucumber.yml
|
219
223
|
- docs/.keep
|
220
224
|
- docs/_config.yml
|
221
225
|
- docs/credits.md
|
@@ -259,6 +263,7 @@ files:
|
|
259
263
|
- lib/chutney/linter/missing_test_action.rb
|
260
264
|
- lib/chutney/linter/missing_verification.rb
|
261
265
|
- lib/chutney/linter/required_tags_starts_with.rb
|
266
|
+
- lib/chutney/linter/same_tag_different_case.rb
|
262
267
|
- lib/chutney/linter/same_tag_for_all_scenarios.rb
|
263
268
|
- lib/chutney/linter/scenario_names_match.rb
|
264
269
|
- lib/chutney/linter/tag_used_multiple_times.rb
|
@@ -289,17 +294,17 @@ require_paths:
|
|
289
294
|
- lib
|
290
295
|
required_ruby_version: !ruby/object:Gem::Requirement
|
291
296
|
requirements:
|
292
|
-
- - "
|
297
|
+
- - "~>"
|
293
298
|
- !ruby/object:Gem::Version
|
294
|
-
version: '
|
299
|
+
version: '2.6'
|
295
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
296
301
|
requirements:
|
297
302
|
- - ">="
|
298
303
|
- !ruby/object:Gem::Version
|
299
304
|
version: '0'
|
300
305
|
requirements: []
|
301
|
-
rubygems_version: 3.1.
|
306
|
+
rubygems_version: 3.1.4
|
302
307
|
signing_key:
|
303
308
|
specification_version: 4
|
304
|
-
summary: A linter for
|
309
|
+
summary: A linter for multi-lingual Gherkin
|
305
310
|
test_files: []
|