lint_trap 0.0.2 → 0.0.3

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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +97 -0
  3. data/Dockerfile +222 -0
  4. data/Gemfile +2 -0
  5. data/Rakefile +45 -0
  6. data/circle.yml +22 -0
  7. data/config/checkstyle/checkstyle_logger-all.jar +0 -0
  8. data/config/checkstyle/sun_checks.xml +177 -0
  9. data/config/coffeelint/lint_trap.coffee +12 -0
  10. data/config/jshint/formatter.js +22 -0
  11. data/config/rubocop/formatter.rb +22 -0
  12. data/config/scsslint/scsslint +34 -0
  13. data/lib/lint_trap/command.rb +39 -0
  14. data/lib/lint_trap/container/base.rb +30 -0
  15. data/lib/lint_trap/container/docker.rb +46 -0
  16. data/lib/lint_trap/container/fake.rb +28 -0
  17. data/lib/lint_trap/language/base.rb +18 -0
  18. data/lib/lint_trap/language/coffeescript.rb +13 -0
  19. data/lib/lint_trap/language/cpp.rb +17 -0
  20. data/lib/lint_trap/language/css.rb +13 -0
  21. data/lib/lint_trap/language/go.rb +13 -0
  22. data/lib/lint_trap/language/java.rb +13 -0
  23. data/lib/lint_trap/language/javascript.rb +13 -0
  24. data/lib/lint_trap/language/json.rb +13 -0
  25. data/lib/lint_trap/language/python.rb +13 -0
  26. data/lib/lint_trap/language/ruby.rb +13 -0
  27. data/lib/lint_trap/language/scss.rb +13 -0
  28. data/lib/lint_trap/language.rb +50 -0
  29. data/lib/lint_trap/linter/base.rb +58 -0
  30. data/lib/lint_trap/linter/checkstyle.rb +24 -0
  31. data/lib/lint_trap/linter/coffeelint.rb +21 -0
  32. data/lib/lint_trap/linter/cppcheck.rb +18 -0
  33. data/lib/lint_trap/linter/csslint.rb +23 -0
  34. data/lib/lint_trap/linter/golint.rb +19 -0
  35. data/lib/lint_trap/linter/jshint.rb +20 -0
  36. data/lib/lint_trap/linter/jsonlint.rb +18 -0
  37. data/lib/lint_trap/linter/pylint.rb +19 -0
  38. data/lib/lint_trap/linter/rubocop.rb +22 -0
  39. data/lib/lint_trap/linter/scsslint.rb +22 -0
  40. data/lib/lint_trap/linter.rb +42 -0
  41. data/lib/lint_trap/{parsers/base_parser.rb → parser/base.rb} +8 -9
  42. data/lib/lint_trap/{parsers/csslint_parser.rb → parser/csslint.rb} +4 -5
  43. data/lib/lint_trap/{parsers/line_parser.rb → parser/line.rb} +14 -5
  44. data/lib/lint_trap/parser/standard.rb +22 -0
  45. data/lib/lint_trap/parser/vim_quickfix.rb +19 -0
  46. data/lib/lint_trap/version.rb +1 -1
  47. data/lib/lint_trap.rb +5 -14
  48. data/lint_trap.gemspec +3 -0
  49. data/spec/command_spec.rb +38 -0
  50. data/spec/container/docker_spec.rb +34 -0
  51. data/spec/container/fake_spec.rb +29 -0
  52. data/spec/fixtures/Good.java +6 -0
  53. data/spec/fixtures/bad.coffee +1 -0
  54. data/spec/fixtures/bad.cpp +5 -0
  55. data/spec/fixtures/bad.css +4 -0
  56. data/spec/fixtures/bad.go +7 -0
  57. data/spec/fixtures/bad.java +3 -0
  58. data/spec/fixtures/bad.js +3 -0
  59. data/spec/fixtures/bad.json +4 -0
  60. data/spec/fixtures/bad.py +2 -0
  61. data/spec/fixtures/bad.rb +4 -0
  62. data/spec/fixtures/bad.scss +3 -0
  63. data/spec/fixtures/good.coffee +1 -0
  64. data/spec/fixtures/good.cpp +4 -0
  65. data/spec/fixtures/good.css +3 -0
  66. data/spec/fixtures/good.go +7 -0
  67. data/spec/fixtures/good.js +5 -0
  68. data/spec/fixtures/good.json +4 -0
  69. data/spec/fixtures/good.py +6 -0
  70. data/spec/fixtures/good.rb +5 -0
  71. data/spec/fixtures/good.scss +3 -0
  72. data/spec/fixtures/lint.txt +1 -0
  73. data/spec/integration/checkstyle_spec.rb +52 -0
  74. data/spec/integration/coffeelint_spec.rb +44 -0
  75. data/spec/integration/cppcheck_spec.rb +60 -0
  76. data/spec/integration/csslint_spec.rb +44 -0
  77. data/spec/integration/golint_spec.rb +44 -0
  78. data/spec/integration/jshint_spec.rb +70 -0
  79. data/spec/integration/jsonlint_spec.rb +60 -0
  80. data/spec/integration/pylint_spec.rb +51 -0
  81. data/spec/integration/rubocop_spec.rb +52 -0
  82. data/spec/integration/scsslint_spec.rb +44 -0
  83. data/spec/language/coffeescript_spec.rb +8 -0
  84. data/spec/language/cpp_spec.rb +8 -0
  85. data/spec/language/css_spec.rb +8 -0
  86. data/spec/language/go_spec.rb +8 -0
  87. data/spec/language/java_spec.rb +8 -0
  88. data/spec/language/javascript_spec.rb +8 -0
  89. data/spec/language/json_spec.rb +8 -0
  90. data/spec/language/python_spec.rb +8 -0
  91. data/spec/language/ruby_spec.rb +8 -0
  92. data/spec/language/scss_spec.rb +8 -0
  93. data/spec/language_spec.rb +143 -0
  94. data/spec/lint_trap_spec.rb +0 -16
  95. data/spec/linter/checkstyle_spec.rb +45 -0
  96. data/spec/linter/coffeelint_spec.rb +46 -0
  97. data/spec/linter/cppcheck_spec.rb +26 -0
  98. data/spec/linter/csslint_spec.rb +44 -0
  99. data/spec/linter/golint_spec.rb +22 -0
  100. data/spec/linter/jshint_spec.rb +44 -0
  101. data/spec/linter/jsonlint_spec.rb +22 -0
  102. data/spec/linter/pylint_spec.rb +46 -0
  103. data/spec/linter/rubocop_spec.rb +48 -0
  104. data/spec/linter/scsslint_spec.rb +44 -0
  105. data/spec/linter_spec.rb +67 -0
  106. data/spec/parser/csslint_spec.rb +25 -0
  107. data/spec/{parsers/standard_parser_spec.rb → parser/standard_spec.rb} +4 -3
  108. data/spec/{parsers/vim_quickfix_parser_spec.rb → parser/vim_quickfix_spec.rb} +5 -4
  109. data/spec/spec_helper.rb +8 -0
  110. data/spec/support/fixture_file_helper.rb +8 -0
  111. metadata +193 -18
  112. data/lib/lint_trap/parser_factory.rb +0 -32
  113. data/lib/lint_trap/parsers/null_parser.rb +0 -11
  114. data/lib/lint_trap/parsers/standard_parser.rb +0 -23
  115. data/lib/lint_trap/parsers/vim_quickfix_parser.rb +0 -20
  116. data/spec/parser_factory_spec.rb +0 -17
  117. data/spec/parsers/csslint_parser_spec.rb +0 -26
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::JSHint do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ subject(:linter){described_class.new(container: container)}
6
+
7
+ shared_examples '#lint' do
8
+ context 'when linting a bad file' do
9
+ let(:file){fixture_path('bad.js')}
10
+
11
+ it 'generates lint' do
12
+ expect{|b| linter.lint([file], &b)}.to yield_successive_args(
13
+ {
14
+ file: file,
15
+ line: '2',
16
+ column: '13',
17
+ length: nil,
18
+ rule: 'E031',
19
+ severity: 'error',
20
+ message: 'Bad assignment.'
21
+ }, {
22
+ file: file,
23
+ line: '2',
24
+ column: '13',
25
+ length: nil,
26
+ rule: 'W030',
27
+ severity: 'warning',
28
+ message:
29
+ 'Expected an assignment or function call and instead saw an expression.'
30
+ }, {
31
+ file: file,
32
+ line: '2',
33
+ column: '14',
34
+ length: nil,
35
+ rule: 'W033',
36
+ severity: 'warning',
37
+ message: 'Missing semicolon.'
38
+ }, {
39
+ file: file,
40
+ line: '2',
41
+ column: '15',
42
+ length: nil,
43
+ rule: 'W030',
44
+ severity: 'warning',
45
+ message:
46
+ 'Expected an assignment or function call and instead saw an expression.'
47
+ }
48
+ )
49
+ end
50
+ end
51
+
52
+ context 'when linting a good file' do
53
+ let(:file){fixture_path('good.js')}
54
+
55
+ it 'generates no lint' do
56
+ expect{|b| linter.lint([file], &b)}.to_not yield_control
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'with docker container', if: !ENV['SKIP_DOCKER'] do
62
+ let(:container){LintTrap::Container::Docker.new('lintci/spin_cycle:latest', fixture_path)}
63
+
64
+ it_behaves_like '#lint'
65
+ end
66
+
67
+ context 'without a docker container', if: ENV['SKIP_DOCKER'] do
68
+ it_behaves_like '#lint'
69
+ end
70
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::JSONLint do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ subject(:linter){described_class.new(container: container)}
6
+
7
+ shared_examples '#lint' do
8
+ context 'when linting a bad file' do
9
+ let(:file){fixture_path('bad.json')}
10
+
11
+ it 'generates lint' do
12
+ expect{|b| linter.lint([file], &b)}.to yield_successive_args(
13
+ {
14
+ file: file,
15
+ line: '2',
16
+ column: '2',
17
+ length: nil,
18
+ rule: nil,
19
+ severity: 'error',
20
+ message: 'Json strings must use double quotes'
21
+ }, {
22
+ file: file,
23
+ line: '3',
24
+ column: '2',
25
+ length: nil,
26
+ rule: nil,
27
+ severity: 'error',
28
+ message: 'Keys must be double quoted in Json. Did you mean "not"?'
29
+ }, {
30
+ file: file,
31
+ line: '3',
32
+ column: '7',
33
+ length: nil,
34
+ rule: nil,
35
+ severity: 'error',
36
+ message: 'Invalid Json number'
37
+ }
38
+ )
39
+ end
40
+ end
41
+
42
+ context 'when linting a good file' do
43
+ let(:file){fixture_path('good.json')}
44
+
45
+ it 'generates no lint' do
46
+ expect{|b| linter.lint([file], &b)}.to_not yield_control
47
+ end
48
+ end
49
+ end
50
+
51
+ context 'with docker container', if: !ENV['SKIP_DOCKER'] do
52
+ let(:container){LintTrap::Container::Docker.new('lintci/spin_cycle:latest', fixture_path)}
53
+
54
+ it_behaves_like '#lint'
55
+ end
56
+
57
+ context 'without a docker container', if: ENV['SKIP_DOCKER'] do
58
+ it_behaves_like '#lint'
59
+ end
60
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::PyLint do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ subject(:linter){described_class.new(container: container)}
6
+
7
+ shared_examples '#lint' do
8
+ context 'when linting a bad file' do
9
+ let(:file){fixture_path('bad.py')}
10
+
11
+ it 'generates lint' do
12
+ expect{|b| linter.lint([file], &b)}.to yield_successive_args(
13
+ {
14
+ file: file,
15
+ line: '1',
16
+ column: '0',
17
+ length: nil,
18
+ rule: 'missing-docstring',
19
+ severity: 'convention',
20
+ message: 'Missing module docstring'
21
+ }, {
22
+ file: file,
23
+ line: '1',
24
+ column: '0',
25
+ length: nil,
26
+ rule: 'missing-docstring',
27
+ severity: 'convention',
28
+ message: 'Missing function docstring'}
29
+ )
30
+ end
31
+ end
32
+
33
+ context 'when linting a good file' do
34
+ let(:file){fixture_path('good.py')}
35
+
36
+ it 'generates no lint' do
37
+ expect{|b| linter.lint([file], &b)}.to_not yield_control
38
+ end
39
+ end
40
+ end
41
+
42
+ context 'with docker container', if: !ENV['SKIP_DOCKER'] do
43
+ let(:container){LintTrap::Container::Docker.new('lintci/spin_cycle:latest', fixture_path)}
44
+
45
+ it_behaves_like '#lint'
46
+ end
47
+
48
+ context 'without a docker container', if: ENV['SKIP_DOCKER'] do
49
+ it_behaves_like '#lint'
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::RuboCop do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ subject(:linter){described_class.new(container: container)}
6
+
7
+ shared_examples '#lint' do
8
+ context 'when linting a bad file' do
9
+ let(:file){fixture_path('bad.rb')}
10
+
11
+ it 'generates lint' do
12
+ expect{|b| linter.lint([file], &b)}.to yield_successive_args(
13
+ {
14
+ file: file,
15
+ line: '1',
16
+ column: '1',
17
+ length: '5',
18
+ rule: 'Style/Documentation',
19
+ severity: 'convention',
20
+ message: 'Missing top-level class documentation comment.'
21
+ }, {
22
+ file: file,
23
+ line: '2',
24
+ column: '7',
25
+ length: '4',
26
+ rule: 'Style/MethodName',
27
+ severity: 'convention',
28
+ message: 'Use snake_case for method names.'
29
+ }
30
+ )
31
+ end
32
+ end
33
+
34
+ context 'when linting a good file' do
35
+ let(:file){fixture_path('good.rb')}
36
+
37
+ it 'generates no lint' do
38
+ expect{|b| linter.lint([file], &b)}.to_not yield_control
39
+ end
40
+ end
41
+ end
42
+
43
+ context 'with docker container', if: !ENV['SKIP_DOCKER'] do
44
+ let(:container){LintTrap::Container::Docker.new('lintci/spin_cycle:latest', fixture_path)}
45
+
46
+ it_behaves_like '#lint'
47
+ end
48
+
49
+ context 'without a docker container', if: ENV['SKIP_DOCKER'] do
50
+ it_behaves_like '#lint'
51
+ end
52
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::SCSSLint do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ subject(:linter){described_class.new(container: container)}
6
+
7
+ shared_examples '#lint' do
8
+ context 'when linting a bad file' do
9
+ let(:file){fixture_path('bad.scss')}
10
+
11
+ it 'generates lint' do
12
+ expect{|b| linter.lint([file], &b)}.to yield_successive_args(
13
+ {
14
+ file: file,
15
+ line: '2',
16
+ column: '3',
17
+ length: '12',
18
+ rule: 'BorderZero',
19
+ severity: 'warning',
20
+ message: '`border: 0;` is preferred over `border: none;`'
21
+ }
22
+ )
23
+ end
24
+ end
25
+
26
+ context 'when linting a good file' do
27
+ let(:file){fixture_path('good.scss')}
28
+
29
+ it 'generates no lint' do
30
+ expect{|b| linter.lint([file], &b)}.to_not yield_control
31
+ end
32
+ end
33
+ end
34
+
35
+ context 'with docker container', if: !ENV['SKIP_DOCKER'] do
36
+ let(:container){LintTrap::Container::Docker.new('lintci/spin_cycle:latest', fixture_path)}
37
+
38
+ it_behaves_like '#lint'
39
+ end
40
+
41
+ context 'without a docker container', if: ENV['SKIP_DOCKER'] do
42
+ it_behaves_like '#lint'
43
+ end
44
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::CoffeeScript do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('CoffeeScript')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::CoffeeLint])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::CPP do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('C++')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::CPPCheck])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::CSS do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('CSS')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::CSSLint])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::Go do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('Go')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::GoLint])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::Java do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('Java')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::CheckStyle])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::JavaScript do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('JavaScript')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::JSHint])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::JSON do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('JSON')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::JSONLint])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::Python do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('Python')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::PyLint])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::Ruby do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('Ruby')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::RuboCop])}
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language::SCSS do
4
+ subject(:language){described_class.new}
5
+
6
+ its(:name){is_expected.to eq('SCSS')}
7
+ its(:linters){is_expected.to eq([LintTrap::Linter::SCSSLint])}
8
+ end
@@ -0,0 +1,143 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Language do
4
+ describe '.detect' do
5
+ subject(:language){described_class.detect(file)}
6
+
7
+ context 'when given a CoffeeScript file' do
8
+ let(:file){fixture_path('good.coffee')}
9
+
10
+ it{is_expected.to eq(described_class::CoffeeScript)}
11
+ end
12
+
13
+ context 'when given a C++ file' do
14
+ let(:file){fixture_path('good.cpp')}
15
+
16
+ it{is_expected.to eq(described_class::CPP)}
17
+ end
18
+
19
+ context 'when given a CSS file' do
20
+ let(:file){fixture_path('good.css')}
21
+
22
+ it{is_expected.to eq(described_class::CSS)}
23
+ end
24
+
25
+ context 'when given a Go file' do
26
+ let(:file){fixture_path('good.go')}
27
+
28
+ it{is_expected.to eq(described_class::Go)}
29
+ end
30
+
31
+ context 'when given a Java file' do
32
+ let(:file){fixture_path('Good.java')}
33
+
34
+ it{is_expected.to eq(described_class::Java)}
35
+ end
36
+
37
+ context 'when given a JavaScript file' do
38
+ let(:file){fixture_path('good.js')}
39
+
40
+ it{is_expected.to eq(described_class::JavaScript)}
41
+ end
42
+
43
+ context 'when given a JSON file' do
44
+ let(:file){fixture_path('good.json')}
45
+
46
+ it{is_expected.to eq(described_class::JSON)}
47
+ end
48
+
49
+ context 'when given a Python file' do
50
+ let(:file){fixture_path('good.py')}
51
+
52
+ it{is_expected.to eq(described_class::Python)}
53
+ end
54
+
55
+ context 'when given a Ruby file' do
56
+ let(:file){fixture_path('good.rb')}
57
+
58
+ it{is_expected.to eq(described_class::Ruby)}
59
+ end
60
+
61
+ context 'when given a SCSS file' do
62
+ let(:file){fixture_path('good.scss')}
63
+
64
+ it{is_expected.to eq(described_class::SCSS)}
65
+ end
66
+
67
+ context 'when given an unknown language file' do
68
+ let(:file){fixture_path('lint.txt')}
69
+
70
+ it{is_expected.to eq(nil)}
71
+ end
72
+ end
73
+
74
+ describe '.find' do
75
+ subject(:language){described_class.find(language_name)}
76
+
77
+ context 'when given CoffeeScript' do
78
+ let(:language_name){'CoffeeScript'}
79
+
80
+ it{is_expected.to eq(described_class::CoffeeScript)}
81
+ end
82
+
83
+ context 'when given C++' do
84
+ let(:language_name){'C++'}
85
+
86
+ it{is_expected.to eq(described_class::CPP)}
87
+ end
88
+
89
+ context 'when given CSS' do
90
+ let(:language_name){'CSS'}
91
+
92
+ it{is_expected.to eq(described_class::CSS)}
93
+ end
94
+
95
+ context 'when given Go' do
96
+ let(:language_name){'Go'}
97
+
98
+ it{is_expected.to eq(described_class::Go)}
99
+ end
100
+
101
+ context 'when given Java' do
102
+ let(:language_name){'Java'}
103
+
104
+ it{is_expected.to eq(described_class::Java)}
105
+ end
106
+
107
+ context 'when given JavaScript' do
108
+ let(:language_name){'JavaScript'}
109
+
110
+ it{is_expected.to eq(described_class::JavaScript)}
111
+ end
112
+
113
+ context 'when given JSON' do
114
+ let(:language_name){'JSON'}
115
+
116
+ it{is_expected.to eq(described_class::JSON)}
117
+ end
118
+
119
+ context 'when given Python' do
120
+ let(:language_name){'Python'}
121
+
122
+ it{is_expected.to eq(described_class::Python)}
123
+ end
124
+
125
+ context 'when given Ruby' do
126
+ let(:language_name){'Ruby'}
127
+
128
+ it{is_expected.to eq(described_class::Ruby)}
129
+ end
130
+
131
+ context 'when given SCSS' do
132
+ let(:language_name){'SCSS'}
133
+
134
+ it{is_expected.to eq(described_class::SCSS)}
135
+ end
136
+
137
+ context 'when given an invalid language' do
138
+ let(:language_name){'invalid language'}
139
+
140
+ it{is_expected.to eq(nil)}
141
+ end
142
+ end
143
+ end
@@ -4,20 +4,4 @@ describe LintTrap do
4
4
  it 'has a version number' do
5
5
  expect(LintTrap::VERSION).not_to be nil
6
6
  end
7
-
8
- describe '.parse' do
9
- let(:io){StringIO.new("bad.rb:2:7:4:Style/MethodName:convention:Use snake_case for methods.\n")}
10
-
11
- it 'yields the expected violations' do
12
- expect{|b| LintTrap.parse('rubocop', io, &b)}.to yield_successive_args({
13
- file: 'bad.rb',
14
- line: '2',
15
- column: '7',
16
- length: '4',
17
- rule: 'Style/MethodName',
18
- severity: 'convention',
19
- message: 'Use snake_case for methods.'
20
- })
21
- end
22
- end
23
7
  end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::CheckStyle do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ let(:config){nil}
6
+ let(:files){%w(Good.java bad.java)}
7
+ subject(:linter){described_class.new(container: container, config: config)}
8
+ let(:command){instance_double(LintTrap::Command)}
9
+
10
+ describe '#lint' do
11
+ context 'when config is provided' do
12
+ let(:config){'checks.xml'}
13
+
14
+ it 'runs the lint command with the correct arguments' do
15
+ expect(LintTrap::Command).to receive(:new).with(
16
+ 'java',
17
+ [
18
+ '-jar', container.config_path(described_class::JAR),
19
+ '-c', config
20
+ ],
21
+ files
22
+ ).and_return(command)
23
+ expect(command).to receive(:run).with(container)
24
+
25
+ linter.lint(files)
26
+ end
27
+ end
28
+
29
+ context 'when config is not provided' do
30
+ it 'runs the lint command with the correct arguments' do
31
+ expect(LintTrap::Command).to receive(:new).with(
32
+ 'java',
33
+ [
34
+ '-jar', container.config_path(described_class::JAR),
35
+ '-c', container.config_path(described_class::CHECKS_XML)
36
+ ],
37
+ files
38
+ ).and_return(command)
39
+ expect(command).to receive(:run).with(container)
40
+
41
+ linter.lint(files)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::CoffeeLint do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ let(:config){nil}
6
+ let(:files){%w(good.coffee bad.coffee)}
7
+ subject(:linter){described_class.new(container: container, config: config)}
8
+ let(:command){instance_double(LintTrap::Command)}
9
+
10
+ describe '#lint' do
11
+ context 'when config is provided' do
12
+ let(:config){'coffeelint.json'}
13
+
14
+ it 'runs the lint command with the correct arguments' do
15
+ expect(LintTrap::Command).to receive(:new).with(
16
+ 'coffeelint',
17
+ [
18
+ "--reporter=#{container.config_path(described_class::REPORTER)}",
19
+ '--nocolor',
20
+ '--file=coffeelint.json'
21
+ ],
22
+ files
23
+ ).and_return(command)
24
+ expect(command).to receive(:run).with(container)
25
+
26
+ linter.lint(files)
27
+ end
28
+ end
29
+
30
+ context 'when config is not provided' do
31
+ it 'runs the lint command with the correct arguments' do
32
+ expect(LintTrap::Command).to receive(:new).with(
33
+ 'coffeelint',
34
+ [
35
+ "--reporter=#{container.config_path(described_class::REPORTER)}",
36
+ '--nocolor'
37
+ ],
38
+ files
39
+ ).and_return(command)
40
+ expect(command).to receive(:run).with(container)
41
+
42
+ linter.lint(files)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe LintTrap::Linter::CPPCheck do
4
+ let(:container){LintTrap::Container::Fake.new}
5
+ let(:config){nil}
6
+ let(:files){%w(good.cpp bad.cpp)}
7
+ subject(:linter){described_class.new(container: container, config: config)}
8
+ let(:command){instance_double(LintTrap::Command)}
9
+
10
+ describe '#lint' do
11
+ it 'runs the lint command with the correct arguments' do
12
+ expect(LintTrap::Command).to receive(:new).with(
13
+ 'cppcheck',
14
+ [
15
+ '--enable=all',
16
+ '--error-exitcode=1',
17
+ '--template="{file}:{line}:::{id}:{severity}:{message}"'
18
+ ],
19
+ files
20
+ ).and_return(command)
21
+ expect(command).to receive(:run).with(container)
22
+
23
+ linter.lint(files)
24
+ end
25
+ end
26
+ end