chutney 3.0.0.beta.1 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +16 -0
- data/.rubocop.yml +4 -3
- data/LICENSE.txt +1 -1
- data/README.md +7 -1
- data/Rakefile +6 -8
- data/chutney.gemspec +9 -6
- data/config/{chutney.yml → chutney_defaults.yml} +2 -0
- data/docs/index.md +1 -1
- data/docs/usage/rules.md +34 -64
- data/exe/chutney +21 -3
- data/lib/chutney.rb +9 -3
- data/lib/chutney/configuration.rb +7 -2
- data/lib/chutney/formatter.rb +4 -5
- data/lib/chutney/formatter/pie_formatter.rb +8 -13
- data/lib/chutney/formatter/rainbow_formatter.rb +11 -13
- data/lib/chutney/linter.rb +50 -43
- data/lib/chutney/linter/avoid_full_stop.rb +1 -3
- data/lib/chutney/linter/avoid_outline_for_single_example.rb +3 -3
- data/lib/chutney/linter/avoid_scripting.rb +2 -2
- data/lib/chutney/linter/background_does_more_than_setup.rb +3 -4
- data/lib/chutney/linter/background_requires_multiple_scenarios.rb +1 -1
- data/lib/chutney/linter/bad_scenario_name.rb +2 -2
- data/lib/chutney/linter/file_name_differs_feature_name.rb +3 -3
- data/lib/chutney/linter/givens_after_background.rb +2 -2
- data/lib/chutney/linter/invalid_file_name.rb +1 -1
- data/lib/chutney/linter/invalid_step_flow.rb +2 -2
- data/lib/chutney/linter/missing_example_name.rb +2 -4
- data/lib/chutney/linter/missing_feature_description.rb +1 -1
- data/lib/chutney/linter/missing_feature_name.rb +2 -2
- data/lib/chutney/linter/missing_scenario_name.rb +1 -2
- data/lib/chutney/linter/missing_test_action.rb +1 -1
- data/lib/chutney/linter/missing_verification.rb +1 -1
- data/lib/chutney/linter/required_tags_starts_with.rb +5 -6
- data/lib/chutney/linter/same_tag_different_case.rb +37 -0
- data/lib/chutney/linter/same_tag_for_all_scenarios.rb +9 -9
- data/lib/chutney/linter/scenario_names_match.rb +2 -3
- data/lib/chutney/linter/tag_used_multiple_times.rb +1 -1
- data/lib/chutney/linter/too_clumsy.rb +1 -1
- data/lib/chutney/linter/too_long_step.rb +3 -3
- data/lib/chutney/linter/too_many_different_tags.rb +6 -6
- data/lib/chutney/linter/too_many_steps.rb +3 -3
- data/lib/chutney/linter/too_many_tags.rb +3 -3
- data/lib/chutney/linter/unique_scenario_names.rb +2 -2
- data/lib/chutney/linter/unknown_variable.rb +3 -3
- data/lib/chutney/linter/unused_variable.rb +3 -4
- data/lib/chutney/linter/use_background.rb +4 -4
- data/lib/chutney/linter/use_outline.rb +7 -7
- data/lib/chutney/version.rb +1 -1
- data/lib/config/locales/en.yml +3 -0
- data/spec/chutney_spec.rb +9 -9
- metadata +17 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9a4331eb00fea09babefa186ea7d1e51f13bacbd56cf381cf3fb3d58f293346
|
4
|
+
data.tar.gz: 16b169146ac5034d46eee9d6858a6b219d854b00d71445a5baca5d6532340b4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a8000d183486b9c3201ff22e43fbcfc316d5117b68539aae88b0d22ec2d9d549fdd945c8a4a15393f14d147e53c038923be3aa1dda3483a6066fb58a48ff50f
|
7
|
+
data.tar.gz: a9a32669fb7ddfd30e742647883a079b654e570b2e6653996a8c9ea26fe1601a402148aabf357e6a79f9150d9f747c8ce6fc80b8036180e3a5b53b3096930950
|
@@ -0,0 +1,16 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
open-pull-requests-limit: 10
|
8
|
+
ignore:
|
9
|
+
- dependency-name: rubocop
|
10
|
+
versions:
|
11
|
+
- 1.10.0
|
12
|
+
- 1.11.0
|
13
|
+
- 1.12.0
|
14
|
+
- 1.12.1
|
15
|
+
- 1.9.0
|
16
|
+
- 1.9.1
|
data/.rubocop.yml
CHANGED
@@ -25,7 +25,8 @@ Layout/LineLength:
|
|
25
25
|
# Offense count: 1
|
26
26
|
# Configuration parameters: CountComments.
|
27
27
|
Metrics/MethodLength:
|
28
|
-
Max:
|
28
|
+
Max: 20
|
29
|
+
|
29
30
|
|
30
31
|
# Offense count: 1
|
31
32
|
# Cop supports --auto-correct.
|
@@ -52,11 +53,11 @@ Layout/HeredocIndentation:
|
|
52
53
|
- "**/*_spec.rb"
|
53
54
|
|
54
55
|
Layout/TrailingWhitespace:
|
55
|
-
Enabled:
|
56
|
+
Enabled: true
|
56
57
|
|
57
58
|
Style/FrozenStringLiteralComment:
|
58
59
|
Enabled: true
|
59
|
-
|
60
|
+
|
60
61
|
Style/StringConcatenation:
|
61
62
|
Enabled: false
|
62
63
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -19,4 +19,10 @@
|
|
19
19
|
|
20
20
|
</div>
|
21
21
|
|
22
|
-
Read the documentation [here](https://billyruffian.github.io/chutney/).
|
22
|
+
Read the documentation [here](https://billyruffian.github.io/chutney/) or try [Chutney Online](https://chutney.billy-ruffian.co.uk).
|
23
|
+
|
24
|
+
See [this page](https://billyruffian.github.io/chutney/usage/rules.html) for a full list of the rules chutney encourages.
|
25
|
+
|
26
|
+
## Notes
|
27
|
+
|
28
|
+
Chutney 3+ has replaced its direct dependency on Cucumber and instead uses the excellent [cuke_modeller](https://github.com/enkessler/cuke_modeler) to parse your feature files.
|
data/Rakefile
CHANGED
@@ -18,14 +18,12 @@ end
|
|
18
18
|
|
19
19
|
desc 'Checks ruby style'
|
20
20
|
task :rubocop do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
puts 'Rubocop failed'
|
28
|
-
end
|
21
|
+
sh 'rubocop -a'
|
22
|
+
rescue RuntimeError => e
|
23
|
+
# Rubocop failing due to style violations is fine. Other errors should bubble up to our attention.
|
24
|
+
raise e unless e.message =~ /status \(1\).*rubocop/
|
25
|
+
|
26
|
+
puts 'Rubocop failed'
|
29
27
|
end
|
30
28
|
|
31
29
|
task :spec do
|
data/chutney.gemspec
CHANGED
@@ -15,8 +15,12 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.email = ['nigel@brookes-thomas.co.uk']
|
16
16
|
|
17
17
|
spec.summary = 'A linter for multi-lingual Gherkin'
|
18
|
-
spec.description = 'A linter for your Cucumber features. '
|
19
|
-
|
18
|
+
spec.description = 'A linter for your Cucumber features. ' \
|
19
|
+
'Making sure you have nice, expressible Gherkin is ' \
|
20
|
+
'essential is making sure you have a readable test-base. ' \
|
21
|
+
'Chutney is designed to sniff out smells in your feature ' \
|
22
|
+
'files. ' \
|
23
|
+
'It supports any spoken language Cucumber supports.'
|
20
24
|
|
21
25
|
spec.homepage = 'https://billyruffian.github.io/chutney/'
|
22
26
|
spec.license = 'MIT'
|
@@ -46,20 +50,19 @@ Gem::Specification.new do |spec|
|
|
46
50
|
|
47
51
|
spec.add_runtime_dependency 'amatch', '~> 0.4.0'
|
48
52
|
spec.add_runtime_dependency 'cuke_modeler', '~> 3.3'
|
49
|
-
spec.add_runtime_dependency 'gherkin', '>= 5.1.0', '< 9.1'
|
50
53
|
spec.add_runtime_dependency 'i18n', '~> 1.8.2'
|
51
54
|
spec.add_runtime_dependency 'pastel', '~> 0.7'
|
52
55
|
spec.add_runtime_dependency 'tty-pie', '~> 0.3'
|
53
56
|
|
54
57
|
|
55
58
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
56
|
-
spec.add_development_dependency 'cucumber', '~>
|
59
|
+
spec.add_development_dependency 'cucumber', '~> 6.0'
|
57
60
|
spec.add_development_dependency 'pry-byebug', '~> 3.0'
|
58
61
|
spec.add_development_dependency 'rake', '~> 13.0'
|
59
62
|
spec.add_development_dependency 'rerun', '~> 0.13'
|
60
63
|
spec.add_development_dependency 'rspec-expectations', '~> 3.0'
|
61
|
-
spec.add_development_dependency 'rubocop', '~>
|
64
|
+
spec.add_development_dependency 'rubocop', '~> 1.14.0'
|
62
65
|
spec.add_development_dependency 'rspec', '~> 3.8'
|
63
66
|
|
64
|
-
spec.required_ruby_version = '
|
67
|
+
spec.required_ruby_version = '>= 2.6'
|
65
68
|
end
|
data/docs/index.md
CHANGED
@@ -18,4 +18,4 @@ You're trying to follow TDD or ATDD principles, you're writing executable specif
|
|
18
18
|
|
19
19
|
Cucumber itself is an awesome tool which bridges with gap between business language, software development language and the language of testers. With all these folks interested, it's easy to write problematic and hard to maintain features. Chutney tries to help with that by having a common set of quality rules for your feature files.
|
20
20
|
|
21
|
-
Chutney is able to lint feature files in any spoken language supported by Cucumber
|
21
|
+
Chutney is able to lint feature files in any spoken language supported by Cucumber.
|
data/docs/usage/rules.md
CHANGED
@@ -9,98 +9,68 @@ nav_order: 2
|
|
9
9
|
|
10
10
|
Chutney enforces its rules with the linters. These are:
|
11
11
|
|
12
|
-
[AvoidFullStop](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_full_stop.feature)
|
13
|
-
: Don't have a full stop (period) at the end of step because it makes step reuse really hard.
|
12
|
+
[AvoidFullStop](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_full_stop.feature): Don't have a full stop (period) at the end of step because it makes step reuse really hard.
|
14
13
|
|
15
|
-
[AvoidOutlineForSingleExample](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_outline_for_single_example.feature)
|
16
|
-
: If you only have a single example in your example table, use a plain-old scenario instead.
|
14
|
+
[AvoidOutlineForSingleExample](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_outline_for_single_example.feature): If you only have a single example in your example table, use a plain-old scenario instead.
|
17
15
|
|
18
|
-
[AvoidScripting](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_scripting.feature)
|
19
|
-
: You have a lot of steps, are you sure you're not scripting the scenario when you should be specifying the behaviour of the system?
|
16
|
+
[AvoidScripting](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_scripting.feature): You have a lot of steps, are you sure you're not scripting the scenario when you should be specifying the behaviour of the system?
|
20
17
|
|
21
|
-
[AvoidTypographersQuotes](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_typographers_quotes.feature)
|
22
|
-
: Cutting and pasting from Word documents? Is that pasting in curly-quotes instead of neutral ones you would type on a keyboard? Are you sure that's what you want?
|
18
|
+
[AvoidTypographersQuotes](https://github.com/BillyRuffian/chutney/blob/master/features/avoid_typographers_quotes.feature): Cutting and pasting from Word documents? Is that pasting in curly-quotes instead of neutral ones you would type on a keyboard? Are you sure that's what you want?
|
23
19
|
|
24
|
-
[BackgroundDoesMoreThanSetup](https://github.com/BillyRuffian/chutney/blob/master/features/background_does_more_than_setup.feature)
|
25
|
-
: Background in feature files should only do setup activity and so they should only contain `Given` steps.
|
20
|
+
[BackgroundDoesMoreThanSetup](https://github.com/BillyRuffian/chutney/blob/master/features/background_does_more_than_setup.feature): Background in feature files should only do setup activity and so they should only contain `Given` steps.
|
26
21
|
|
27
|
-
[BackgroundRequiresMultipleScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/background_requires_multiple_scenarios.feature)
|
28
|
-
: If you only have one scenario, don't bother having a Background section.
|
22
|
+
[BackgroundRequiresMultipleScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/background_requires_multiple_scenarios.feature): If you only have one scenario, don't bother having a Background section.
|
29
23
|
|
30
|
-
[BadScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/bad_scenario_name.feature)
|
31
|
-
: You should avoid using words like 'test' or 'check' in your scenario names, instead you should define the behaviour of your system.
|
24
|
+
[BadScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/bad_scenario_name.feature): You should avoid using words like 'test' or 'check' in your scenario names, instead you should define the behaviour of your system.
|
32
25
|
|
33
|
-
[EmptyFeatureFile](https://github.com/BillyRuffian/chutney/blob/master/features/empty_feature_file.feature)
|
34
|
-
: The feature should have content and should avoid committing empty features to repositories.
|
26
|
+
[EmptyFeatureFile](https://github.com/BillyRuffian/chutney/blob/master/features/empty_feature_file.feature): The feature should have content and should avoid committing empty features to repositories.
|
35
27
|
|
36
|
-
[FileNameDiffersFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/file_name_differs_feature_name.feature)
|
37
|
-
: The feature should have a name that follows the file name.
|
28
|
+
[FileNameDiffersFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/file_name_differs_feature_name.feature): The feature should have a name that follows the file name.
|
38
29
|
|
39
|
-
[GivensAfterBackground](https://github.com/BillyRuffian/chutney/blob/master/features/givens_after_background.feature)
|
40
|
-
: If you have a Background section and your scenario needs more preconditions then it should start immediately with an `And` step and not another `Given`.
|
30
|
+
[GivensAfterBackground](https://github.com/BillyRuffian/chutney/blob/master/features/givens_after_background.feature): If you have a Background section and your scenario needs more preconditions then it should start immediately with an `And` step and not another `Given`.
|
41
31
|
|
42
|
-
[InvalidFileName](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_file_name.feature)
|
43
|
-
: Make sure your file name is in snake case, not mixed case or with spaces.
|
32
|
+
[InvalidFileName](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_file_name.feature): Make sure your file name is in snake case, not mixed case or with spaces.
|
44
33
|
|
45
|
-
[InvalidStepFlow](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_step_flow.feature)
|
46
|
-
: Your scenarios should follow Given → When → Then, in that order.
|
34
|
+
[InvalidStepFlow](https://github.com/BillyRuffian/chutney/blob/master/features/invalid_step_flow.feature): Your scenarios should follow Given → When → Then, in that order.
|
47
35
|
|
48
|
-
[MissingExampleName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_example_name.feature)
|
49
|
-
: If you have more than one example table in your scenario, they should each be given unique names.
|
36
|
+
[MissingExampleName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_example_name.feature): If you have more than one example table in your scenario, they should each be given unique names.
|
50
37
|
|
51
|
-
[MissingFeatureDescription](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_description.feature)
|
52
|
-
: Your feature should have a value statement. These are usually in the form 'As a... I want.. So that...'.
|
38
|
+
[MissingFeatureDescription](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_description.feature): Your feature should have a value statement. These are usually in the form 'As a... I want.. So that...'.
|
53
39
|
|
54
|
-
[MissingFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_name.feature)
|
55
|
-
: You should give your features a descriptive name.
|
40
|
+
[MissingFeatureName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_feature_name.feature): You should give your features a descriptive name.
|
56
41
|
|
57
|
-
[MissingScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_scenario_name.feature)
|
58
|
-
: You should name your scenarios and scenario outlines.
|
42
|
+
[MissingScenarioName](https://github.com/BillyRuffian/chutney/blob/master/features/missing_scenario_name.feature): You should name your scenarios and scenario outlines.
|
59
43
|
|
60
|
-
[MissingTestAction](https://github.com/BillyRuffian/chutney/blob/master/features/missing_test_action.feature)
|
61
|
-
: You don't have an action (a `When` step) in your scenario.
|
44
|
+
[MissingTestAction](https://github.com/BillyRuffian/chutney/blob/master/features/missing_test_action.feature): You don't have an action (a `When` step) in your scenario.
|
62
45
|
|
63
|
-
[MissingVerification](https://github.com/BillyRuffian/chutney/blob/master/features/missing_verification.feature)
|
64
|
-
: You don't have a verification step (a `Then` step) in your scenario.
|
46
|
+
[MissingVerification](https://github.com/BillyRuffian/chutney/blob/master/features/missing_verification.feature): You don't have a verification step (a `Then` step) in your scenario.
|
65
47
|
|
66
|
-
[RequiredTagsStartWith](https://github.com/BillyRuffian/chutney/blob/master/features/required_tags_starts_with.feature)
|
67
|
-
: Chutney can enforce a configurable naming prefix for your tags.
|
48
|
+
[RequiredTagsStartWith](https://github.com/BillyRuffian/chutney/blob/master/features/required_tags_starts_with.feature): Chutney can enforce a configurable naming prefix for your tags.
|
68
49
|
|
69
|
-
[
|
70
|
-
: You have the same tag for all you scenarios; move the tag to the feature level instead.
|
50
|
+
[SameTagForDifferentCase](https://github.com/BillyRuffian/chutney/blob/master/features/same_tag_different_case.feature): Don't mix the case of tags which have already appeared. Cucumber tags are case sensitive. *Since 3.1.0*
|
71
51
|
|
72
|
-
[
|
73
|
-
: Chutney can enforce a naming convention for your scenario names.
|
52
|
+
[SameTagForAllScenarios](https://github.com/BillyRuffian/chutney/blob/master/features/same_tag_for_all_scenarios.feature): You have the same tag for all you scenarios; move the tag to the feature level instead.
|
74
53
|
|
75
|
-
[
|
76
|
-
: Chutney can warn if you have used a tag a lot with a feature.
|
54
|
+
[ScenarioNamesMatch](https://github.com/BillyRuffian/chutney/blob/master/features/scenario_names_match.feature): Chutney can enforce a naming convention for your scenario names.
|
77
55
|
|
78
|
-
[
|
79
|
-
: This is a very long scenario. Consider writing it more concisely.
|
56
|
+
[TagUsedMultipleTimes](https://github.com/BillyRuffian/chutney/blob/master/features/tag_used_multiple_times.feature): Chutney can warn if you have used a tag a lot with a feature.
|
80
57
|
|
81
|
-
[
|
82
|
-
: This is a very long step. Consider writing it more concisely.
|
58
|
+
[TooClumsy](https://github.com/BillyRuffian/chutney/blob/master/features/too_clumsy.feature): This is a very long scenario. Consider writing it more concisely.
|
83
59
|
|
84
|
-
[
|
85
|
-
: This feature has a lot of different tags.
|
60
|
+
[TooLongStep](https://github.com/BillyRuffian/chutney/blob/master/features/too_long_step.feature): This is a very long step. Consider writing it more concisely.
|
86
61
|
|
87
|
-
[
|
88
|
-
: This feature has a lot of steps. Consider writing it more concisely.
|
62
|
+
[TooManyDifferentTags](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_different_tags.feature): This feature has a lot of different tags.
|
89
63
|
|
90
|
-
[
|
91
|
-
: There are a lot of tags in this feature.
|
64
|
+
[TooManySteps](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_steps.feature): This feature has a lot of steps. Consider writing it more concisely.
|
92
65
|
|
93
|
-
[
|
94
|
-
: You have duplicated a scenario name when they should be unique.
|
66
|
+
[TooManyTags](https://github.com/BillyRuffian/chutney/blob/master/features/too_many_tags.feature): There are a lot of tags in this feature.
|
95
67
|
|
96
|
-
[
|
97
|
-
: You are referencing a variable which doesn't appear to be defined. This is a source of subtle errors.
|
68
|
+
[UniqueScenarioNames](https://github.com/BillyRuffian/chutney/blob/master/features/unique_scenario_names.feature): You have duplicated a scenario name when they should be unique.
|
98
69
|
|
99
|
-
[
|
100
|
-
: You have a variable which you are not using.
|
70
|
+
[UnknownVariable](https://github.com/BillyRuffian/chutney/blob/master/features/unknown_variable.feature): You are referencing a variable which doesn't appear to be defined. This is a source of subtle errors.
|
101
71
|
|
102
|
-
[
|
103
|
-
: You have a setup setup used in all of your scenarios. Move it to a Background section.
|
72
|
+
[UnusedVariable](https://github.com/BillyRuffian/chutney/blob/master/features/unused_variable.feature): You have a variable which you are not using.
|
104
73
|
|
105
|
-
[
|
106
|
-
|
74
|
+
[UseBackground](https://github.com/BillyRuffian/chutney/blob/master/features/use_background.feature): You have a setup setup used in all of your scenarios. Move it to a Background section.
|
75
|
+
|
76
|
+
[UseOutline](https://github.com/BillyRuffian/chutney/blob/master/features/use_outline.feature): You have very similar scenarios. You should consider if they should be combined into a Scenario Outline.
|
data/exe/chutney
CHANGED
@@ -12,19 +12,37 @@ formatters = Set.new
|
|
12
12
|
|
13
13
|
OptionParser.new do |opts|
|
14
14
|
opts.banner = 'Usage: chutney [files]'
|
15
|
-
opts.on('-f',
|
16
|
-
'--format [formatter]',
|
15
|
+
opts.on('-f',
|
16
|
+
'--format [formatter]',
|
17
17
|
'One of JSONFormatter, PieFormatter or RainbowFormatter (default).') do |formatter|
|
18
18
|
raise 'No Such Formatter' unless %w[JSONFormatter PieFormatter RainbowFormatter].include? formatter
|
19
19
|
|
20
20
|
formatters << formatter
|
21
21
|
end
|
22
|
+
|
23
|
+
opts.on('-l',
|
24
|
+
'--linters',
|
25
|
+
'List the linter status by this configuration and exit') do
|
26
|
+
pastel = Pastel.new
|
27
|
+
chutney_config = Chutney::ChutneyLint.new.configuration
|
28
|
+
max_name_length = chutney_config.keys.map(&:length).max + 1
|
29
|
+
chutney_config.each do |linter, value|
|
30
|
+
print pastel.cyan(linter.ljust(max_name_length))
|
31
|
+
|
32
|
+
if value['Enabled']
|
33
|
+
puts pastel.green('enabled')
|
34
|
+
else
|
35
|
+
puts pastel.red('disabled')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
exit
|
39
|
+
end
|
22
40
|
end.parse!
|
23
41
|
|
24
42
|
formatters << 'RainbowFormatter' if formatters.empty?
|
25
43
|
|
26
44
|
files = ARGV.map { |pattern| Dir.glob(pattern) }.flatten
|
27
|
-
files = Dir.glob('features/**/*.feature') if ARGV.empty?
|
45
|
+
files = Dir.glob('features/**/*.feature') if ARGV.empty?
|
28
46
|
|
29
47
|
linter = Chutney::ChutneyLint.new(*files)
|
30
48
|
report = linter.analyse
|
data/lib/chutney.rb
CHANGED
@@ -23,6 +23,7 @@ require 'chutney/linter/missing_scenario_name'
|
|
23
23
|
require 'chutney/linter/missing_test_action'
|
24
24
|
require 'chutney/linter/missing_verification'
|
25
25
|
require 'chutney/linter/required_tags_starts_with'
|
26
|
+
require 'chutney/linter/same_tag_different_case'
|
26
27
|
require 'chutney/linter/same_tag_for_all_scenarios'
|
27
28
|
require 'chutney/linter/scenario_names_match'
|
28
29
|
require 'chutney/linter/tag_used_multiple_times'
|
@@ -36,6 +37,7 @@ require 'chutney/linter/unknown_variable'
|
|
36
37
|
require 'chutney/linter/unused_variable'
|
37
38
|
require 'chutney/linter/use_background'
|
38
39
|
require 'chutney/linter/use_outline'
|
40
|
+
require 'chutney/version'
|
39
41
|
|
40
42
|
require 'cuke_modeler'
|
41
43
|
require 'forwardable'
|
@@ -58,14 +60,18 @@ module Chutney
|
|
58
60
|
@files = files
|
59
61
|
@results = Hash.new { |h, k| h[k] = [] }
|
60
62
|
i18n_paths = Dir[File.expand_path(File.join(__dir__, 'config/locales')) + '/*.yml']
|
61
|
-
return if I18n.load_path.include?(i18n_paths)
|
62
63
|
|
63
|
-
|
64
|
+
i18n_paths.each do |path|
|
65
|
+
next if I18n.load_path.include?(path)
|
66
|
+
|
67
|
+
I18n.load_path << path
|
68
|
+
I18n.backend.reload!
|
69
|
+
end
|
64
70
|
end
|
65
71
|
|
66
72
|
def configuration
|
67
73
|
unless @config
|
68
|
-
default_file = [File.expand_path('..', __dir__), '**/config', '
|
74
|
+
default_file = [File.expand_path('..', __dir__), '**/config', 'chutney_defaults.yml']
|
69
75
|
config_file = Dir.glob(File.join(default_file)).first.freeze
|
70
76
|
@config = Configuration.new(config_file)
|
71
77
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'delegate'
|
4
|
-
|
4
|
+
|
5
|
+
module Chutney
|
5
6
|
# gherkin_lint configuration object
|
6
7
|
class Configuration < SimpleDelegator
|
7
8
|
def initialize(path)
|
@@ -20,7 +21,11 @@ module Chutney
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def load_user_configuration
|
23
|
-
|
24
|
+
config_files = ['chutney.yml', '.chutney.yml'].map do |fname|
|
25
|
+
Dir.glob(File.join(Dir.pwd, '**', fname))
|
26
|
+
end.flatten
|
27
|
+
|
28
|
+
config_file = config_files.first
|
24
29
|
merge_config(config_file) if !config_file.nil? && File.exist?(config_file)
|
25
30
|
end
|
26
31
|
|
data/lib/chutney/formatter.rb
CHANGED
@@ -4,18 +4,17 @@ module Chutney
|
|
4
4
|
# base class for all formatters
|
5
5
|
class Formatter
|
6
6
|
attr_accessor :results
|
7
|
-
|
7
|
+
|
8
8
|
def initialize
|
9
9
|
@results = {}
|
10
|
-
end
|
11
|
-
|
10
|
+
end
|
11
|
+
|
12
12
|
def files
|
13
13
|
results.map { |k, _v| k }
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def files_with_issues
|
17
17
|
results.filter { |_k, v| v.any? { |r| r[:issues].count.positive? } }
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
21
20
|
end
|
@@ -6,10 +6,6 @@ require 'tty/pie'
|
|
6
6
|
module Chutney
|
7
7
|
# format results as pie charts
|
8
8
|
class PieFormatter < Formatter
|
9
|
-
def initialize
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
9
|
def format
|
14
10
|
data = top_offences.map do |offence|
|
15
11
|
{
|
@@ -21,14 +17,14 @@ module Chutney
|
|
21
17
|
end
|
22
18
|
print_report(data)
|
23
19
|
end
|
24
|
-
|
20
|
+
|
25
21
|
def print_report(data)
|
26
22
|
return if data.empty?
|
27
23
|
|
28
24
|
print TTY::Pie.new(data: data, radius: 8, legend: { format: '%<label>s %<name>s %<value>i' })
|
29
25
|
puts
|
30
26
|
end
|
31
|
-
|
27
|
+
|
32
28
|
def top_offences
|
33
29
|
offence = Hash.new(0)
|
34
30
|
files_with_issues.each do |_file, linter|
|
@@ -38,9 +34,9 @@ module Chutney
|
|
38
34
|
end
|
39
35
|
offence.reject { |_k, v| v.zero? }.sort_by { |_linter, count| -count }
|
40
36
|
end
|
41
|
-
|
37
|
+
|
42
38
|
def char_loop
|
43
|
-
@char_looper ||= Fiber.new do
|
39
|
+
@char_looper ||= Fiber.new do
|
44
40
|
chars = %w[• x + @ * / -]
|
45
41
|
current = 0
|
46
42
|
loop do
|
@@ -51,10 +47,10 @@ module Chutney
|
|
51
47
|
end
|
52
48
|
@char_looper.resume
|
53
49
|
end
|
54
|
-
|
50
|
+
|
55
51
|
def colour_loop
|
56
|
-
@colour_looper ||= Fiber.new do
|
57
|
-
colours = %i[bright_cyan bright_magenta bright_yellow bright_green]
|
52
|
+
@colour_looper ||= Fiber.new do
|
53
|
+
colours = %i[bright_cyan bright_magenta bright_yellow bright_green]
|
58
54
|
current = 0
|
59
55
|
loop do
|
60
56
|
current = 0 if current >= colours.count
|
@@ -64,7 +60,7 @@ module Chutney
|
|
64
60
|
end
|
65
61
|
@colour_looper.resume
|
66
62
|
end
|
67
|
-
|
63
|
+
|
68
64
|
def put_summary
|
69
65
|
pastel = Pastel.new
|
70
66
|
print "#{files.count} features inspected, "
|
@@ -74,6 +70,5 @@ module Chutney
|
|
74
70
|
puts pastel.red("#{files_with_issues.count} taste nasty")
|
75
71
|
end
|
76
72
|
end
|
77
|
-
|
78
73
|
end
|
79
74
|
end
|