gherkin_lint 0.6.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +19 -1
  4. data/Dockerfile +2 -0
  5. data/Gemfile +3 -2
  6. data/README.md +24 -2
  7. data/Rakefile +3 -3
  8. data/bin/gherkin_lint +10 -2
  9. data/config/default.yml +58 -0
  10. data/features/avoid_outline_for_single_example.feature +2 -1
  11. data/features/avoid_period.feature +1 -1
  12. data/features/avoid_scripting.feature +1 -1
  13. data/features/background_does_more_than_setup.feature +1 -1
  14. data/features/background_requires_scenario.feature +1 -1
  15. data/features/bad_scenario_name.feature +1 -1
  16. data/features/be_declarative.feature +1 -1
  17. data/features/disable_tags.feature +1 -2
  18. data/features/file_name_differs_feature_name.feature +2 -2
  19. data/features/invalid_file_name.feature +1 -1
  20. data/features/invalid_step_flow.feature +1 -1
  21. data/features/missing_example_name.feature +1 -2
  22. data/features/missing_feature_description.feature +1 -1
  23. data/features/missing_feature_name.feature +1 -1
  24. data/features/missing_scenario_name.feature +1 -1
  25. data/features/missing_test_action.feature +1 -2
  26. data/features/missing_verification.feature +1 -2
  27. data/features/precedence.feature +72 -0
  28. data/features/required_tags_starts_with.feature +95 -0
  29. data/features/same_tag_for_all_scenarios.feature +1 -5
  30. data/features/support/env.rb +72 -0
  31. data/features/tag_used_multiple_times.feature +1 -1
  32. data/features/too_clumsy.feature +1 -1
  33. data/features/too_long_step.feature +1 -1
  34. data/features/too_many_different_tags.feature +1 -1
  35. data/features/too_many_steps.feature +1 -1
  36. data/features/too_many_tags.feature +1 -1
  37. data/features/unique_scenario_names.feature +1 -1
  38. data/features/unknown_variable.feature +1 -1
  39. data/features/unused_variable.feature +1 -1
  40. data/features/use_background.feature +1 -2
  41. data/features/use_outline.feature +1 -2
  42. data/gherkin_lint.gemspec +3 -3
  43. data/lib/gherkin_lint.rb +44 -51
  44. data/lib/gherkin_lint/configuration.rb +32 -0
  45. data/lib/gherkin_lint/issue.rb +1 -1
  46. data/lib/gherkin_lint/linter.rb +6 -10
  47. data/lib/gherkin_lint/linter/avoid_scripting.rb +1 -1
  48. data/lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb +1 -1
  49. data/lib/gherkin_lint/linter/bad_scenario_name.rb +1 -1
  50. data/lib/gherkin_lint/linter/be_declarative.rb +10 -8
  51. data/lib/gherkin_lint/linter/required_tags_starts_with.rb +16 -0
  52. data/lib/gherkin_lint/linter/tag_collector.rb +9 -0
  53. data/lib/gherkin_lint/linter/tag_constraint.rb +32 -0
  54. data/lib/gherkin_lint/linter/too_many_different_tags.rb +3 -0
  55. data/lib/gherkin_lint/linter/too_many_tags.rb +3 -0
  56. data/spec/configuration_spec.rb +58 -0
  57. data/spec/gherkin_lint_spec.rb +68 -0
  58. data/spec/required_tags_starts_with_spec.rb +74 -0
  59. data/spec/shared_contexts/file_exists.rb +12 -0
  60. data/spec/shared_contexts/gherkin_linter.rb +14 -0
  61. metadata +18 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a0564cbdd460a09454d8abeebefc4e04a7f2a74
4
- data.tar.gz: 73ae15d6afbb81cabc6953429d6fafc1616f86e9
3
+ metadata.gz: 1b9ad10d82b638f8b53bea62cc731d72f0285537
4
+ data.tar.gz: 0a779d0729f79747f9fc9f776c12ca3453341a76
5
5
  SHA512:
6
- metadata.gz: d1951a9f14e1fee9ff34b83bb1335b74cb7a76a3b6183242fbe10af169e193b0053cbb7a117eb4c2b178dea6b255be092f901b702210cd99795f5fdd7c0c197c
7
- data.tar.gz: 0d1e213a2656598e2515dce0a94ab3708f7f6f7b6fc95b6e9c24aefc1c633161b943e43cfa6e837ecbd7411606be4a4b34bc63fc78aab5af971709fec23a28ba
6
+ metadata.gz: edc57cb10fb6f52db675742da92d40924b2c3cf49cd104b02ad04d2379eab61b4cbf484bcd0c6f62cd9787f6f26f9f22caab60ee36cacedde3730f358f13b13a
7
+ data.tar.gz: c066a1bd07d54b6e911581abe31bc0b74781eddb20cc0a8abac59b0c934eb0ef4f8968614a43a3152d34b3d8f954a87d55d02a20df318266d42a8a3e57e9b165
@@ -0,0 +1,4 @@
1
+ Gemfile.lock
2
+ .bundle
3
+ .idea
4
+ tmp
@@ -20,7 +20,8 @@ Metrics/ClassLength:
20
20
  # URISchemes: http, https
21
21
  Metrics/LineLength:
22
22
  Max: 116
23
-
23
+ Exclude:
24
+ - "**/*_spec.rb"
24
25
  # Offense count: 1
25
26
  # Configuration parameters: CountComments.
26
27
  Metrics/MethodLength:
@@ -33,3 +34,20 @@ Metrics/MethodLength:
33
34
  Style/NumericPredicate:
34
35
  Exclude:
35
36
  - 'lib/gherkin_lint/linter/file_name_differs_feature_name.rb'
37
+
38
+ Metrics/ModuleLength:
39
+ Exclude:
40
+ - "**/*_spec.rb"
41
+
42
+ Metrics/BlockLength:
43
+ Exclude:
44
+ - "**/*_spec.rb"
45
+
46
+ Layout/IndentationWidth:
47
+ Exclude:
48
+ - "**/*_spec.rb"
49
+
50
+ Layout/IndentHeredoc:
51
+ Exclude:
52
+ - "**/*_spec.rb"
53
+
data/Dockerfile CHANGED
@@ -3,5 +3,7 @@ MAINTAINER think@hotmail.de
3
3
 
4
4
  RUN gem install gherkin_lint --no-format-exec
5
5
 
6
+ ENV LC_ALL=C.UTF-8
7
+
6
8
  ENTRYPOINT ["gherkin_lint"]
7
9
  CMD ["--help"]
data/Gemfile CHANGED
@@ -1,10 +1,11 @@
1
1
  source 'https://rubygems.org'
2
- gem 'aruba'
3
2
  gem 'amatch'
3
+ gem 'aruba'
4
+ gem 'engtagger', '>=0.2.1'
4
5
  gem 'gherkin', '>=4.0.0'
5
6
  # TODO: update to gherkin4 gem 'gherkin_format'
6
7
  # TODO: update to gherkin4 gem 'gherkin_language'
7
8
  gem 'rake'
9
+ gem 'rspec'
8
10
  gem 'rubocop'
9
11
  gem 'term-ansicolor'
10
- gem 'engtagger', '>=0.2.1'
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/funkwerk/gherkin_lint.svg)](https://travis-ci.org/funkwerk/gherkin_lint)
4
4
  [![Code Climate](https://codeclimate.com/github/funkwerk/gherkin_lint/badges/gpa.svg)](https://codeclimate.com/github/funkwerk/gherkin_lint)
5
+ [![Docker Build](https://img.shields.io/docker/automated/gherkin/lint.svg)](https://hub.docker.com/r/gherkin/lint/)
6
+ [![Downloads](https://img.shields.io/gem/dt/gherkin_lint.svg)](https://rubygems.org/gems/gherkin_lint)
7
+ [![Latest Tag](https://img.shields.io/github/tag/funkwerk/gherkin_lint.svg)](https://rubygems.org/gems/gherkin_lint)
5
8
 
6
9
  This tool lints gherkin files.
7
10
 
@@ -9,13 +12,20 @@ This tool lints gherkin files.
9
12
 
10
13
  run `gherkin_lint` on a list of files
11
14
 
12
- gherkin_lint FEATURE_FILES
15
+ gherkin_lint -f '<wild_card_path>' #default is `features/**/*.feature`
13
16
 
14
- With `--disable CHECK` or `--enable CHECK` it's possible to disable respectivly enable program wide checks.
17
+ With `--disable CHECK` or `--enable CHECK` it's possible to disable respectivly enable program wide checks except when a linter requires additional values to be set in order to be valid. Currently only RequiredTagStartsWith meets this criteria.
15
18
 
16
19
  Checks could be disabled using tags within Feature Files. To do so, add @disableCHECK.
17
20
  Detailed usage within the [disable_tags](https://github.com/funkwerk/gherkin_lint/blob/master/features/disable_tags.feature) feature.
18
21
 
22
+ ### Usage with Docker
23
+
24
+ Assuming there are feature files in the current directory. Then call.
25
+
26
+ `docker run -ti -v $(pwd):/src -w /src gherkin/lint *.feature`
27
+
28
+ This will mount the current directory within the Gherkin Lint Docker Container and then check all feature files.
19
29
 
20
30
  ## Checks
21
31
 
@@ -35,6 +45,7 @@ Detailed usage within the [disable_tags](https://github.com/funkwerk/gherkin_lin
35
45
  - [missing scenario name](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_scenario_name.feature)
36
46
  - [missing test action](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_test_action.feature)
37
47
  - [missing verification](https://github.com/funkwerk/gherkin_lint/blob/master/features/missing_verification.feature)
48
+ - [required tag starts with](https://github.com/funkwerk/gherkin_lint/blob/master/features/required_tag_starts_with.feature) - disabled by default
38
49
  - [same tag for all scenarios](https://github.com/funkwerk/gherkin_lint/blob/master/features/same_tag_for_all_scenarios.feature)
39
50
  - [tag used multiple times](https://github.com/funkwerk/gherkin_lint/blob/master/features/tag_used_multiple_times.feature)
40
51
  - [too clumsy](https://github.com/funkwerk/gherkin_lint/blob/master/features/too_clumsy.feature)
@@ -59,3 +70,14 @@ These new checks will stay some releases as warning and will be later declared a
59
70
  ### Errors
60
71
 
61
72
  If there is at least one error, the returncode will be set to ERROR (!= 0).
73
+
74
+ ## Installation
75
+
76
+ Install it with:
77
+
78
+ `sudo gem install gherkin_lint`
79
+
80
+ After that `gherkin_lint` executable is available.
81
+
82
+ ## Configuration
83
+ If you have a custom configuration you'd like to run on a regular basis instead of passing enable and disable flags through the CLI on every run, you can configure a ```.gherkin_lint.yml``` file that will be loaded on execution. The format and available linters are in [```config/default.yml```](config/default.yml)
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  desc 'Publishes the Gem'
13
13
  task :push do
14
- sh 'gem push gherkin_lint-0.6.3.gem'
14
+ sh 'gem push gherkin_lint-1.0.0.gem'
15
15
  end
16
16
 
17
17
  desc 'Checks ruby style'
@@ -36,9 +36,9 @@ task :language do
36
36
  end
37
37
 
38
38
  task :self_check do
39
- disabled_checks = %w(
39
+ disabled_checks = %w[
40
40
  UnknownVariable
41
41
  BadScenarioName
42
- )
42
+ ]
43
43
  sh "RUBYLIB=lib ./bin/gherkin_lint --disable #{disabled_checks.join ','} features/*.feature"
44
44
  end
@@ -14,13 +14,21 @@ OptionParser.new do |opts|
14
14
  opts.on('--disable [CHECKS]', 'Disabled checks. Separated by ","') do |checks|
15
15
  options[:disable] = checks.split(',')
16
16
  end
17
+ opts.on('-f', '--filepath [file/s]', 'File path where features are located') do |file|
18
+ options[:files] = file
19
+ end
17
20
  end.parse!
18
21
 
19
22
  linter = GherkinLint::GherkinLint.new
20
-
21
23
  linter.disable options[:disable] if options.key? :disable
22
24
  linter.enable options[:enable] if options.key? :enable
25
+ linter.set_linter
26
+
27
+ options[:files] = 'features/**/*.feature' if options[:files].nil?
28
+ files = Dir.glob(options[:files])
23
29
 
24
- ARGV.each { |file| linter.analyze file }
30
+ files.each do |file|
31
+ linter.analyze file
32
+ end
25
33
 
26
34
  exit linter.report
@@ -0,0 +1,58 @@
1
+ AvoidOutlineForSingleExample:
2
+ Enabled: true
3
+ AvoidPeriod:
4
+ Enabled: true
5
+ AvoidScripting:
6
+ Enabled: true
7
+ BackgroundDoesMoreThanSetup:
8
+ Enabled: true
9
+ BackgroundRequiresMultipleScenarios:
10
+ Enabled: true
11
+ BadScenarioName:
12
+ Enabled: true
13
+ BeDeclarative:
14
+ Enabled: true
15
+ FileNameDiffersFeatureName:
16
+ Enabled: true
17
+ MissingExampleName:
18
+ Enabled: true
19
+ MissingFeatureDescription:
20
+ Enabled: true
21
+ MissingFeatureName:
22
+ Enabled: true
23
+ MissingScenarioName:
24
+ Enabled: true
25
+ MissingTestAction:
26
+ Enabled: true
27
+ MissingVerification:
28
+ Enabled: true
29
+ InvalidFileName:
30
+ Enabled: true
31
+ InvalidStepFlow:
32
+ Enabled: true
33
+ RequiredTagsStartsWith:
34
+ Enabled: false
35
+ SameTagForAllScenarios:
36
+ Enabled: true
37
+ TagUsedMultipleTimes:
38
+ Enabled: true
39
+ TooClumsy:
40
+ Enabled: true
41
+ TooManyDifferentTags:
42
+ Enabled: true
43
+ TooManySteps:
44
+ Enabled: true
45
+ TooManyTags:
46
+ Enabled: true
47
+ TooLongStep:
48
+ Enabled: true
49
+ UniqueScenarioNames:
50
+ Enabled: true
51
+ UnknownVariable:
52
+ Enabled: true
53
+ UnusedVariable:
54
+ Enabled: true
55
+ UseBackground:
56
+ Enabled: true
57
+ UseOutline:
58
+ Enabled: true
@@ -4,6 +4,7 @@ Feature: Avoid Outline for single Example
4
4
  so that it's easier to reuse verification steps
5
5
 
6
6
  Background: Prepare Testee
7
+
7
8
  Given a file named "lint.rb" with:
8
9
  """
9
10
  $LOAD_PATH << '../../lib'
@@ -11,6 +12,7 @@ Feature: Avoid Outline for single Example
11
12
 
12
13
  linter = GherkinLint::GherkinLint.new
13
14
  linter.enable %w(AvoidOutlineForSingleExample)
15
+ linter.set_linter
14
16
  linter.analyze 'lint.feature'
15
17
  exit linter.report
16
18
 
@@ -52,5 +54,4 @@ Feature: Avoid Outline for single Example
52
54
  When I run `ruby lint.rb`
53
55
  Then it should pass with exactly:
54
56
  """
55
-
56
57
  """
@@ -11,6 +11,7 @@ Feature: Avoid Period
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(AvoidPeriod)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -45,5 +46,4 @@ Feature: Avoid Period
45
46
  When I run `ruby lint.rb`
46
47
  Then it should pass with exactly:
47
48
  """
48
-
49
49
  """
@@ -11,6 +11,7 @@ Feature: Avoid Scripting
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(AvoidScripting)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -65,5 +66,4 @@ Feature: Avoid Scripting
65
66
  When I run `ruby lint.rb`
66
67
  Then it should pass with exactly:
67
68
  """
68
-
69
69
  """
@@ -11,6 +11,7 @@ Feature: Background Does More Than Setup
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(BackgroundDoesMoreThanSetup)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -42,5 +43,4 @@ Feature: Background Does More Than Setup
42
43
  When I run `ruby lint.rb`
43
44
  Then it should pass with exactly:
44
45
  """
45
-
46
46
  """
@@ -11,6 +11,7 @@ Feature: Background Requires Scenario
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(BackgroundRequiresMultipleScenarios)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -53,5 +54,4 @@ Feature: Background Requires Scenario
53
54
  When I run `ruby lint.rb`
54
55
  Then it should pass with exactly:
55
56
  """
56
-
57
57
  """
@@ -11,6 +11,7 @@ Feature: Bad Scenario Name
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(BadScenarioName)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -49,5 +50,4 @@ Feature: Bad Scenario Name
49
50
  When I run `ruby lint.rb`
50
51
  Then it should pass with exactly:
51
52
  """
52
-
53
53
  """
@@ -11,6 +11,7 @@ Feature: Be Declarative
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(BeDeclarative)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -49,5 +50,4 @@ Feature: Be Declarative
49
50
  When I run `ruby lint.rb`
50
51
  Then it should pass with exactly:
51
52
  """
52
-
53
53
  """
@@ -11,6 +11,7 @@ Feature: Disable Tags
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(InvalidStepFlow)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -54,7 +55,6 @@ Feature: Disable Tags
54
55
  When I run `ruby lint.rb`
55
56
  Then it should pass with exactly:
56
57
  """
57
-
58
58
  """
59
59
 
60
60
  Scenario: Disable on Feature Level
@@ -73,5 +73,4 @@ Feature: Disable Tags
73
73
  When I run `ruby lint.rb`
74
74
  Then it should pass with exactly:
75
75
  """
76
-
77
76
  """
@@ -11,6 +11,7 @@ Feature: File Name Differs Feature Name
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(FileNameDiffersFeatureName)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -37,7 +38,6 @@ Feature: File Name Differs Feature Name
37
38
  When I run `ruby lint.rb lint.feature`
38
39
  Then it should pass with exactly:
39
40
  """
40
-
41
41
  """
42
42
 
43
43
  Examples: Valid Names
@@ -54,6 +54,7 @@ Feature: File Name Differs Feature Name
54
54
 
55
55
  linter = GherkinLint::GherkinLint.new
56
56
  linter.enable %w(FileNameDiffersFeatureName)
57
+ linter.set_linter
57
58
  linter.analyze 'lint_test.feature'
58
59
  exit linter.report
59
60
 
@@ -65,7 +66,6 @@ Feature: File Name Differs Feature Name
65
66
  When I run `ruby lint.rb lint_test.feature`
66
67
  Then it should pass with exactly:
67
68
  """
68
-
69
69
  """
70
70
 
71
71
  Examples: Valid Names
@@ -13,6 +13,7 @@ Feature: Invalid File Name
13
13
 
14
14
  linter = GherkinLint::GherkinLint.new
15
15
  linter.enable %w(InvalidFileName)
16
+ linter.set_linter
16
17
  ARGV.each { |file| linter.analyze file }
17
18
  exit linter.report
18
19
 
@@ -46,5 +47,4 @@ Feature: Invalid File Name
46
47
  When I run `ruby lint.rb lint.feature`
47
48
  Then it should pass with exactly:
48
49
  """
49
-
50
50
  """
@@ -11,6 +11,7 @@ Feature: Invalid Step Flow
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(InvalidStepFlow)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -81,5 +82,4 @@ Feature: Invalid Step Flow
81
82
  When I run `ruby lint.rb`
82
83
  Then it should pass with exactly:
83
84
  """
84
-
85
85
  """
@@ -11,6 +11,7 @@ Feature: Missing Example Name
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(MissingExampleName)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -57,7 +58,6 @@ Feature: Missing Example Name
57
58
  When I run `ruby lint.rb`
58
59
  Then it should pass with exactly:
59
60
  """
60
-
61
61
  """
62
62
 
63
63
  Scenario: Valid Example
@@ -83,5 +83,4 @@ Feature: Missing Example Name
83
83
  When I run `ruby lint.rb`
84
84
  Then it should pass with exactly:
85
85
  """
86
-
87
86
  """
@@ -11,6 +11,7 @@ Feature: Missing Feature Description
11
11
 
12
12
  linter = GherkinLint::GherkinLint.new
13
13
  linter.enable %w(MissingFeatureDescription)
14
+ linter.set_linter
14
15
  linter.analyze 'lint.feature'
15
16
  exit linter.report
16
17
 
@@ -40,5 +41,4 @@ Feature: Missing Feature Description
40
41
  When I run `ruby lint.rb`
41
42
  Then it should pass with exactly:
42
43
  """
43
-
44
44
  """