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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +16 -0
  3. data/.rubocop.yml +10 -3
  4. data/Gemfile +2 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.md +7 -1
  7. data/Rakefile +8 -8
  8. data/chutney.gemspec +13 -6
  9. data/config/{chutney.yml → chutney_defaults.yml} +2 -0
  10. data/config/cucumber.yml +1 -0
  11. data/docs/index.md +1 -1
  12. data/docs/usage/rules.md +34 -64
  13. data/exe/chutney +23 -3
  14. data/lib/chutney.rb +18 -14
  15. data/lib/chutney/configuration.rb +9 -2
  16. data/lib/chutney/formatter.rb +6 -5
  17. data/lib/chutney/formatter/json_formatter.rb +2 -0
  18. data/lib/chutney/formatter/pie_formatter.rb +10 -13
  19. data/lib/chutney/formatter/rainbow_formatter.rb +13 -13
  20. data/lib/chutney/issue.rb +2 -0
  21. data/lib/chutney/linter.rb +92 -86
  22. data/lib/chutney/linter/avoid_full_stop.rb +4 -4
  23. data/lib/chutney/linter/avoid_outline_for_single_example.rb +7 -5
  24. data/lib/chutney/linter/avoid_scripting.rb +8 -6
  25. data/lib/chutney/linter/avoid_typographers_quotes.rb +16 -14
  26. data/lib/chutney/linter/background_does_more_than_setup.rb +8 -7
  27. data/lib/chutney/linter/background_requires_multiple_scenarios.rb +7 -4
  28. data/lib/chutney/linter/bad_scenario_name.rb +6 -4
  29. data/lib/chutney/linter/empty_feature_file.rb +2 -0
  30. data/lib/chutney/linter/file_name_differs_feature_name.rb +7 -5
  31. data/lib/chutney/linter/givens_after_background.rb +7 -8
  32. data/lib/chutney/linter/invalid_file_name.rb +3 -1
  33. data/lib/chutney/linter/invalid_step_flow.rb +9 -9
  34. data/lib/chutney/linter/missing_example_name.rb +9 -9
  35. data/lib/chutney/linter/missing_feature_description.rb +5 -4
  36. data/lib/chutney/linter/missing_feature_name.rb +5 -4
  37. data/lib/chutney/linter/missing_scenario_name.rb +4 -6
  38. data/lib/chutney/linter/missing_test_action.rb +4 -2
  39. data/lib/chutney/linter/missing_verification.rb +4 -2
  40. data/lib/chutney/linter/required_tags_starts_with.rb +7 -6
  41. data/lib/chutney/linter/same_tag_different_case.rb +37 -0
  42. data/lib/chutney/linter/same_tag_for_all_scenarios.rb +20 -19
  43. data/lib/chutney/linter/scenario_names_match.rb +6 -6
  44. data/lib/chutney/linter/tag_used_multiple_times.rb +3 -1
  45. data/lib/chutney/linter/too_clumsy.rb +4 -2
  46. data/lib/chutney/linter/too_long_step.rb +6 -4
  47. data/lib/chutney/linter/too_many_different_tags.rb +10 -8
  48. data/lib/chutney/linter/too_many_steps.rb +6 -4
  49. data/lib/chutney/linter/too_many_tags.rb +5 -3
  50. data/lib/chutney/linter/unique_scenario_names.rb +5 -5
  51. data/lib/chutney/linter/unknown_variable.rb +15 -15
  52. data/lib/chutney/linter/unused_variable.rb +15 -16
  53. data/lib/chutney/linter/use_background.rb +20 -19
  54. data/lib/chutney/linter/use_outline.rb +15 -14
  55. data/lib/chutney/version.rb +3 -1
  56. data/lib/config/locales/en.yml +3 -0
  57. data/spec/chutney_spec.rb +11 -9
  58. data/spec/spec_helper.rb +2 -0
  59. 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.include?(:children)
40
-
41
- feature[:children].each do |scenario|
42
- next unless scenario[:type] == :Scenario
43
- next unless scenario.include? :steps
44
- next if scenario[:steps].empty?
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[:keyword]}: #{scenario[:name]}"
55
- reference[:text] = scenario[:steps].map { |step| render_step(step) }.join ' '
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Chutney
2
- VERSION = '2.2.1'.freeze
4
+ VERSION = '3.1.0'
3
5
  end
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
4
  require 'coveralls'
3
5
  # Coveralls.wear!
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: 2.2.1
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: 2020-08-25 00:00:00.000000000 Z
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: gherkin
31
+ name: cuke_modeler
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: 5.1.0
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: 5.1.0
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: '3.0'
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: '3.0'
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: 0.89.0
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: 0.89.0
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. It supports any spoken language
199
- Cucumber v3 supports.
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/chutney.yml
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: '0'
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.2
306
+ rubygems_version: 3.1.4
302
307
  signing_key:
303
308
  specification_version: 4
304
- summary: A linter for English language Gherkin
309
+ summary: A linter for multi-lingual Gherkin
305
310
  test_files: []