lint_trap 0.0.11 → 0.0.13
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/Dockerfile +1 -1
- data/Rakefile +32 -22
- data/circle.yml +0 -2
- data/config/checkstyle/checkstyle_logger-6.6-all.jar +0 -0
- data/config/checkstyle/sun_checks.xml +2 -1
- data/docker/checkstyle/Dockerfile +19 -0
- data/docker/coffeelint/Dockerfile +21 -0
- data/docker/cppcheck/Dockerfile +24 -0
- data/docker/csslint/Dockerfile +21 -0
- data/docker/golint/Dockerfile +19 -0
- data/docker/jshint/Dockerfile +21 -0
- data/docker/jsonlint/Dockerfile +21 -0
- data/docker/pylint/Dockerfile +24 -0
- data/docker/rubocop/Dockerfile +21 -0
- data/docker/scsslint/Dockerfile +21 -0
- data/lib/lint_trap/command.rb +2 -3
- data/lib/lint_trap/container/base.rb +10 -3
- data/lib/lint_trap/container/docker.rb +16 -3
- data/lib/lint_trap/container/fake.rb +3 -0
- data/lib/lint_trap/execution_error.rb +12 -0
- data/lib/lint_trap/linter/base.rb +29 -18
- data/lib/lint_trap/linter/checkstyle.rb +12 -5
- data/lib/lint_trap/linter/coffeelint.rb +6 -2
- data/lib/lint_trap/linter/cppcheck.rb +5 -1
- data/lib/lint_trap/linter/csslint.rb +6 -2
- data/lib/lint_trap/linter/golint.rb +6 -2
- data/lib/lint_trap/linter/jshint.rb +6 -2
- data/lib/lint_trap/linter/jsonlint.rb +6 -2
- data/lib/lint_trap/linter/pylint.rb +5 -1
- data/lib/lint_trap/linter/rubocop.rb +6 -2
- data/lib/lint_trap/linter/scsslint.rb +7 -3
- data/lib/lint_trap/linter/unknown.rb +4 -0
- data/lib/lint_trap/linter.rb +4 -0
- data/lib/lint_trap/parser/base.rb +1 -1
- data/lib/lint_trap/parser/line.rb +12 -6
- data/lib/lint_trap/version.rb +1 -1
- data/lint_trap.gemspec +15 -14
- data/spec/command_spec.rb +8 -5
- data/spec/container/base_spec.rb +31 -0
- data/spec/container/docker_spec.rb +27 -7
- data/spec/execution_error_spec.rb +11 -0
- data/spec/integration/base_spec.rb +33 -0
- data/spec/integration/checkstyle_spec.rb +1 -1
- data/spec/integration/coffeelint_spec.rb +16 -10
- data/spec/integration/cppcheck_spec.rb +9 -1
- data/spec/integration/csslint_spec.rb +16 -10
- data/spec/integration/golint_spec.rb +8 -10
- data/spec/integration/jshint_spec.rb +9 -1
- data/spec/integration/jsonlint_spec.rb +9 -1
- data/spec/integration/pylint_spec.rb +9 -1
- data/spec/integration/rubocop_spec.rb +9 -1
- data/spec/integration/scsslint_spec.rb +16 -10
- data/spec/language/coffeescript_spec.rb +1 -0
- data/spec/language/cpp_spec.rb +1 -0
- data/spec/language/css_spec.rb +1 -0
- data/spec/language/go_spec.rb +1 -0
- data/spec/language/java_spec.rb +1 -0
- data/spec/language/javascript_spec.rb +1 -0
- data/spec/language/json_spec.rb +1 -0
- data/spec/language/python_spec.rb +1 -0
- data/spec/language/ruby_spec.rb +1 -0
- data/spec/language/scss_spec.rb +1 -0
- data/spec/language/unknown_spec.rb +1 -0
- data/spec/linter/base_spec.rb +24 -0
- data/spec/linter/checkstyle_spec.rb +8 -4
- data/spec/linter/coffeelint_spec.rb +5 -2
- data/spec/linter/cppcheck_spec.rb +4 -1
- data/spec/linter/csslint_spec.rb +5 -2
- data/spec/linter/golint_spec.rb +4 -1
- data/spec/linter/jshint_spec.rb +5 -2
- data/spec/linter/jsonlint_spec.rb +4 -1
- data/spec/linter/pylint_spec.rb +5 -2
- data/spec/linter/rubocop_spec.rb +5 -2
- data/spec/linter/scsslint_spec.rb +5 -2
- data/spec/linter/unknown_spec.rb +3 -0
- data/spec/linter_spec.rb +20 -1
- data/spec/parser/base_spec.rb +13 -0
- data/spec/parser/csslint_spec.rb +3 -1
- data/spec/parser/line_spec.rb +13 -0
- data/spec/parser/standard_spec.rb +4 -2
- data/spec/parser/vim_quickfix_spec.rb +10 -10
- data/spec/spec_helper.rb +15 -0
- data/spec/support/dockerfile.rb +12 -0
- data/spec/support/examples/language.rb +1 -1
- metadata +43 -4
- data/config/checkstyle/checkstyle_logger-all.jar +0 -0
@@ -1,25 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Linter::SCSSLint do
|
4
|
-
let(:container){LintTrap::Container::Docker.new(
|
4
|
+
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path)}
|
5
5
|
let(:options){{}}
|
6
6
|
subject(:linter){described_class.new}
|
7
7
|
|
8
|
+
describe '#version' do
|
9
|
+
subject(:dockerfile){Dockerfile.new(linter.name)}
|
10
|
+
|
11
|
+
it 'matches the linters version' do
|
12
|
+
expect(dockerfile.include_env?('SCSSLINT_VERSION', linter.version)).to be_truthy
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
describe '#lint' do
|
9
17
|
context 'when linting a bad file' do
|
10
18
|
let(:file){fixture_path('bad.scss')}
|
11
19
|
|
12
20
|
it 'generates lint' do
|
13
21
|
expect{|b| linter.lint([file], container, options, &b)}.to yield_successive_args(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
message: '`border: 0;` is preferred over `border: none;`'
|
22
|
-
}
|
22
|
+
file: file,
|
23
|
+
line: '2',
|
24
|
+
column: '3',
|
25
|
+
length: '12',
|
26
|
+
rule: 'BorderZero',
|
27
|
+
severity: 'warning',
|
28
|
+
message: '`border: 0 is preferred over `border: none`'
|
23
29
|
)
|
24
30
|
end
|
25
31
|
end
|
data/spec/language/cpp_spec.rb
CHANGED
data/spec/language/css_spec.rb
CHANGED
data/spec/language/go_spec.rb
CHANGED
data/spec/language/java_spec.rb
CHANGED
data/spec/language/json_spec.rb
CHANGED
data/spec/language/ruby_spec.rb
CHANGED
data/spec/language/scss_spec.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Linter::Base do
|
4
|
+
let(:container){LintTrap::Container::Docker.new('lintci/rubocop', '/src')}
|
5
|
+
subject(:linter) do
|
6
|
+
Class.new(described_class) do
|
7
|
+
def name
|
8
|
+
'ErrorLinter'
|
9
|
+
end
|
10
|
+
end.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#version' do
|
14
|
+
it 'raises an error if not overriden' do
|
15
|
+
expect{linter.version}.to raise_error(NotImplementedError, 'Must implement version.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#lint' do
|
20
|
+
it 'raises an error if #flags is not overriden' do
|
21
|
+
expect{linter.lint([], container, {})}.to raise_error(NotImplementedError, 'Must implement flags.')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -10,6 +10,10 @@ describe LintTrap::Linter::CheckStyle do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::Java.new])}
|
13
|
+
its(:version){is_expected.to eq('6.6')}
|
14
|
+
its(:image){is_expected.to eq('lintci/checkstyle')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/checkstyle:6.6')}
|
16
|
+
its(:jar){is_expected.to eq('checkstyle/checkstyle_logger-6.6-all.jar')}
|
13
17
|
|
14
18
|
describe '#lint' do
|
15
19
|
context 'when config is provided' do
|
@@ -19,12 +23,12 @@ describe LintTrap::Linter::CheckStyle do
|
|
19
23
|
expect(LintTrap::Command).to receive(:new).with(
|
20
24
|
'java',
|
21
25
|
[
|
22
|
-
'-jar', container.config_path(
|
26
|
+
'-jar', container.config_path(linter.jar),
|
23
27
|
'-c', options[:config]
|
24
28
|
],
|
25
29
|
files
|
26
30
|
).and_return(command)
|
27
|
-
expect(command).to receive(:run).with(container)
|
31
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
28
32
|
|
29
33
|
linter.lint(files, container, options)
|
30
34
|
end
|
@@ -35,12 +39,12 @@ describe LintTrap::Linter::CheckStyle do
|
|
35
39
|
expect(LintTrap::Command).to receive(:new).with(
|
36
40
|
'java',
|
37
41
|
[
|
38
|
-
'-jar', container.config_path(
|
42
|
+
'-jar', container.config_path(linter.jar),
|
39
43
|
'-c', container.config_path(described_class::CHECKS_XML)
|
40
44
|
],
|
41
45
|
files
|
42
46
|
).and_return(command)
|
43
|
-
expect(command).to receive(:run).with(container)
|
47
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
44
48
|
|
45
49
|
linter.lint(files, container, options)
|
46
50
|
end
|
@@ -10,6 +10,9 @@ describe LintTrap::Linter::CoffeeLint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::CoffeeScript.new])}
|
13
|
+
its(:version){is_expected.to eq('1.9.7')}
|
14
|
+
its(:image){is_expected.to eq('lintci/coffeelint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/coffeelint:1.9.7')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
context 'when config is provided' do
|
@@ -25,7 +28,7 @@ describe LintTrap::Linter::CoffeeLint do
|
|
25
28
|
],
|
26
29
|
files
|
27
30
|
).and_return(command)
|
28
|
-
expect(command).to receive(:run).with(container)
|
31
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
29
32
|
|
30
33
|
linter.lint(files, container, options)
|
31
34
|
end
|
@@ -41,7 +44,7 @@ describe LintTrap::Linter::CoffeeLint do
|
|
41
44
|
],
|
42
45
|
files
|
43
46
|
).and_return(command)
|
44
|
-
expect(command).to receive(:run).with(container)
|
47
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
45
48
|
|
46
49
|
linter.lint(files, container, options)
|
47
50
|
end
|
@@ -10,6 +10,9 @@ describe LintTrap::Linter::CPPCheck do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::CPP.new])}
|
13
|
+
its(:version){is_expected.to eq('1.67-1')}
|
14
|
+
its(:image){is_expected.to eq('lintci/cppcheck')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/cppcheck:1.67-1')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
it 'runs the lint command with the correct arguments' do
|
@@ -22,7 +25,7 @@ describe LintTrap::Linter::CPPCheck do
|
|
22
25
|
],
|
23
26
|
files
|
24
27
|
).and_return(command)
|
25
|
-
expect(command).to receive(:run).with(container)
|
28
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
26
29
|
|
27
30
|
linter.lint(files, container, options)
|
28
31
|
end
|
data/spec/linter/csslint_spec.rb
CHANGED
@@ -10,6 +10,9 @@ describe LintTrap::Linter::CSSLint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::CSS.new])}
|
13
|
+
its(:version){is_expected.to eq('0.10.0')}
|
14
|
+
its(:image){is_expected.to eq('lintci/csslint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/csslint:0.10.0')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
context 'when config is provided' do
|
@@ -24,7 +27,7 @@ describe LintTrap::Linter::CSSLint do
|
|
24
27
|
],
|
25
28
|
files
|
26
29
|
).and_return(command)
|
27
|
-
expect(command).to receive(:run).with(container)
|
30
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
28
31
|
|
29
32
|
linter.lint(files, container, options)
|
30
33
|
end
|
@@ -39,7 +42,7 @@ describe LintTrap::Linter::CSSLint do
|
|
39
42
|
],
|
40
43
|
files
|
41
44
|
).and_return(command)
|
42
|
-
expect(command).to receive(:run).with(container)
|
45
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
43
46
|
|
44
47
|
linter.lint(files, container, options)
|
45
48
|
end
|
data/spec/linter/golint_spec.rb
CHANGED
@@ -10,6 +10,9 @@ describe LintTrap::Linter::GoLint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::Go.new])}
|
13
|
+
its(:version){is_expected.to eq(LintTrap::VERSION)}
|
14
|
+
its(:image){is_expected.to eq('lintci/golint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/golint:' + LintTrap::VERSION)}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
it 'runs the lint command with the correct arguments' do
|
@@ -18,7 +21,7 @@ describe LintTrap::Linter::GoLint do
|
|
18
21
|
[],
|
19
22
|
files
|
20
23
|
).and_return(command)
|
21
|
-
expect(command).to receive(:run).with(container)
|
24
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
22
25
|
|
23
26
|
linter.lint(files, container, options)
|
24
27
|
end
|
data/spec/linter/jshint_spec.rb
CHANGED
@@ -10,6 +10,9 @@ describe LintTrap::Linter::JSHint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::JavaScript.new])}
|
13
|
+
its(:version){is_expected.to eq('2.5.11')}
|
14
|
+
its(:image){is_expected.to eq('lintci/jshint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/jshint:2.5.11')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
context 'when config is provided' do
|
@@ -24,7 +27,7 @@ describe LintTrap::Linter::JSHint do
|
|
24
27
|
],
|
25
28
|
files
|
26
29
|
).and_return(command)
|
27
|
-
expect(command).to receive(:run).with(container)
|
30
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
28
31
|
|
29
32
|
linter.lint(files, container, options)
|
30
33
|
end
|
@@ -39,7 +42,7 @@ describe LintTrap::Linter::JSHint do
|
|
39
42
|
],
|
40
43
|
files
|
41
44
|
).and_return(command)
|
42
|
-
expect(command).to receive(:run).with(container)
|
45
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
43
46
|
|
44
47
|
linter.lint(files, container, options)
|
45
48
|
end
|
@@ -10,6 +10,9 @@ describe LintTrap::Linter::JSONLint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::JSON.new])}
|
13
|
+
its(:version){is_expected.to eq('0.0.4')}
|
14
|
+
its(:image){is_expected.to eq('lintci/jsonlint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/jsonlint:0.0.4')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
it 'runs the lint command with the correct arguments' do
|
@@ -18,7 +21,7 @@ describe LintTrap::Linter::JSONLint do
|
|
18
21
|
['--format', '{{file}}:{{line}}:{{column}}:::error:{{{description}}}'],
|
19
22
|
files
|
20
23
|
).and_return(command)
|
21
|
-
expect(command).to receive(:run).with(container)
|
24
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
22
25
|
|
23
26
|
linter.lint(files, container, options)
|
24
27
|
end
|
data/spec/linter/pylint_spec.rb
CHANGED
@@ -10,6 +10,9 @@ describe LintTrap::Linter::PyLint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::Python.new])}
|
13
|
+
its(:version){is_expected.to eq('1.3.1-3')}
|
14
|
+
its(:image){is_expected.to eq('lintci/pylint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/pylint:1.3.1-3')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
context 'when config is provided' do
|
@@ -25,7 +28,7 @@ describe LintTrap::Linter::PyLint do
|
|
25
28
|
],
|
26
29
|
files
|
27
30
|
).and_return(command)
|
28
|
-
expect(command).to receive(:run).with(container)
|
31
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
29
32
|
|
30
33
|
linter.lint(files, container, options)
|
31
34
|
end
|
@@ -41,7 +44,7 @@ describe LintTrap::Linter::PyLint do
|
|
41
44
|
],
|
42
45
|
files
|
43
46
|
).and_return(command)
|
44
|
-
expect(command).to receive(:run).with(container)
|
47
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
45
48
|
|
46
49
|
linter.lint(files, container, options)
|
47
50
|
end
|
data/spec/linter/rubocop_spec.rb
CHANGED
@@ -10,6 +10,9 @@ describe LintTrap::Linter::RuboCop do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::Ruby.new])}
|
13
|
+
its(:version){is_expected.to eq('0.31.0')}
|
14
|
+
its(:image){is_expected.to eq('lintci/rubocop')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/rubocop:0.31.0')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
context 'when config is provided' do
|
@@ -26,7 +29,7 @@ describe LintTrap::Linter::RuboCop do
|
|
26
29
|
],
|
27
30
|
files
|
28
31
|
).and_return(command)
|
29
|
-
expect(command).to receive(:run).with(container)
|
32
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
30
33
|
|
31
34
|
linter.lint(files, container, options)
|
32
35
|
end
|
@@ -43,7 +46,7 @@ describe LintTrap::Linter::RuboCop do
|
|
43
46
|
],
|
44
47
|
files
|
45
48
|
).and_return(command)
|
46
|
-
expect(command).to receive(:run).with(container)
|
49
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
47
50
|
|
48
51
|
linter.lint(files, container, options)
|
49
52
|
end
|
@@ -10,6 +10,9 @@ describe LintTrap::Linter::SCSSLint do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::SCSS.new])}
|
13
|
+
its(:version){is_expected.to eq('0.38.0')}
|
14
|
+
its(:image){is_expected.to eq('lintci/scsslint')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/scsslint:0.38.0')}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
context 'when config is provided' do
|
@@ -24,7 +27,7 @@ describe LintTrap::Linter::SCSSLint do
|
|
24
27
|
],
|
25
28
|
files
|
26
29
|
).and_return(command)
|
27
|
-
expect(command).to receive(:run).with(container)
|
30
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
28
31
|
|
29
32
|
linter.lint(files, container, options)
|
30
33
|
end
|
@@ -39,7 +42,7 @@ describe LintTrap::Linter::SCSSLint do
|
|
39
42
|
],
|
40
43
|
files
|
41
44
|
).and_return(command)
|
42
|
-
expect(command).to receive(:run).with(container)
|
45
|
+
expect(command).to receive(:run).with(container).and_return(true)
|
43
46
|
|
44
47
|
linter.lint(files, container, options)
|
45
48
|
end
|
data/spec/linter/unknown_spec.rb
CHANGED
@@ -10,6 +10,9 @@ describe LintTrap::Linter::Unknown do
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
12
|
its(:languages){is_expected.to eq([LintTrap::Language::Unknown.new])}
|
13
|
+
its(:version){is_expected.to eq(LintTrap::VERSION)}
|
14
|
+
its(:image){is_expected.to eq('lintci/unknown')}
|
15
|
+
its(:image_version){is_expected.to eq('lintci/unknown:' + LintTrap::VERSION)}
|
13
16
|
|
14
17
|
describe '#lint' do
|
15
18
|
it 'is a noop' do
|
data/spec/linter_spec.rb
CHANGED
@@ -1,8 +1,27 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Linter do
|
4
|
+
describe '.all' do
|
5
|
+
subject(:all_linters){described_class.all}
|
6
|
+
|
7
|
+
it do
|
8
|
+
is_expected.to match([
|
9
|
+
be_a(described_class::CheckStyle),
|
10
|
+
be_a(described_class::CoffeeLint),
|
11
|
+
be_a(described_class::CPPCheck),
|
12
|
+
be_a(described_class::CSSLint),
|
13
|
+
be_a(described_class::GoLint),
|
14
|
+
be_a(described_class::JSHint),
|
15
|
+
be_a(described_class::JSONLint),
|
16
|
+
be_a(described_class::PyLint),
|
17
|
+
be_a(described_class::RuboCop),
|
18
|
+
be_a(described_class::SCSSLint)
|
19
|
+
])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
4
23
|
describe '.find' do
|
5
|
-
subject(:
|
24
|
+
subject(:linter){described_class.find(linter_name)}
|
6
25
|
|
7
26
|
context 'when given CheckStyle' do
|
8
27
|
let(:linter_name){'CheckStyle'}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Parser::Base do
|
4
|
+
let(:image){LintTrap::Linter::RuboCop.new.image_version}
|
5
|
+
let(:container){LintTrap::Container::Docker.new(image, fixture_path)}
|
6
|
+
subject(:parser){Class.new(described_class).new(StringIO.new, container)}
|
7
|
+
|
8
|
+
describe '#parse' do
|
9
|
+
it 'raises an error if not overriden' do
|
10
|
+
expect{parser.parse}.to raise_error(NotImplementedError, 'Must implement parse.')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/parser/csslint_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe LintTrap::Parser::CSSLint do
|
|
11
11
|
|
12
12
|
describe '.parse' do
|
13
13
|
it 'parses violations from io' do
|
14
|
-
expect{|b| parser.parse(&b)}.to yield_successive_args(
|
14
|
+
expect{|b| @result = parser.parse(&b)}.to yield_successive_args(
|
15
15
|
file: 'bad.css',
|
16
16
|
line: '2',
|
17
17
|
column: '5',
|
@@ -20,6 +20,8 @@ describe LintTrap::Parser::CSSLint do
|
|
20
20
|
severity: 'Error',
|
21
21
|
message: 'Using width with border can sometimes make elements larger than you expect.'
|
22
22
|
)
|
23
|
+
|
24
|
+
expect(@result).to eq("\n")
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Parser::Line do
|
4
|
+
let(:image){LintTrap::Linter::RuboCop.new.image_version}
|
5
|
+
let(:container){LintTrap::Container::Docker.new(image, fixture_path)}
|
6
|
+
subject(:parser){Class.new(described_class).new(StringIO.new('violation'), container)}
|
7
|
+
|
8
|
+
describe '#parse' do
|
9
|
+
it 'raises an error if #violation_regex not overriden' do
|
10
|
+
expect{parser.parse}.to raise_error(NotImplementedError, 'Must implement violation_regex.')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LintTrap::Parser::Standard do
|
4
4
|
let(:parser_output) do
|
5
|
-
|
5
|
+
'bad.java:1:0::com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck:error:'\
|
6
6
|
"Missing a Javadoc comment.\n"\
|
7
7
|
"bad.coffee:1:::camel_case_classes:error:Class names should be camel cased\n"\
|
8
8
|
"bad.js:2:13::W030:warning:Expected an assignment or function call and instead saw an expression.\n"\
|
@@ -16,7 +16,7 @@ describe LintTrap::Parser::Standard do
|
|
16
16
|
|
17
17
|
describe '.parse' do
|
18
18
|
it 'parses violations from io' do
|
19
|
-
expect{|b| parser.parse(&b)}.to yield_successive_args(
|
19
|
+
expect{|b| @result = parser.parse(&b)}.to yield_successive_args(
|
20
20
|
{
|
21
21
|
file: 'bad.java',
|
22
22
|
line: '1',
|
@@ -72,6 +72,8 @@ describe LintTrap::Parser::Standard do
|
|
72
72
|
message: '`border: 0;` is preferred over `border: none;`'
|
73
73
|
}
|
74
74
|
)
|
75
|
+
|
76
|
+
expect(@result).to eq('')
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
@@ -10,17 +10,17 @@ describe LintTrap::Parser::VimQuickfix do
|
|
10
10
|
|
11
11
|
describe '#parse' do
|
12
12
|
it 'parses violations from io' do
|
13
|
-
expect{|b| parser.parse(&b)}.to yield_successive_args(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
message: 'exported function Main should have comment or be unexported'
|
22
|
-
}
|
13
|
+
expect{|b| @result = parser.parse(&b)}.to yield_successive_args(
|
14
|
+
file: 'bad.go',
|
15
|
+
line: '5',
|
16
|
+
column: '1',
|
17
|
+
length: nil,
|
18
|
+
rule: nil,
|
19
|
+
severity: nil,
|
20
|
+
message: 'exported function Main should have comment or be unexported'
|
23
21
|
)
|
22
|
+
|
23
|
+
expect(@result).to eq('')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter '/spec/'
|
6
|
+
add_filter '/config/'
|
7
|
+
|
8
|
+
add_group 'Containers', 'lib/lint_trap/container'
|
9
|
+
add_group 'Languages', 'lib/lint_trap/language'
|
10
|
+
add_group 'Linters', 'lib/lint_trap/linter'
|
11
|
+
add_group 'Parser', 'lib/lint_trap/parser'
|
12
|
+
|
13
|
+
coverage_dir ENV['CIRCLE_ARTIFACTS'] if ENV['CIRCLE_ARTIFACTS']
|
14
|
+
end
|
15
|
+
|
2
16
|
require 'rspec/its'
|
3
17
|
require 'lint_trap'
|
4
18
|
require 'pry'
|
5
19
|
require_relative 'support/fixture_file_helper'
|
20
|
+
require_relative 'support/dockerfile'
|
6
21
|
require_relative 'support/examples/language'
|
7
22
|
require_relative 'support/examples/linter'
|
8
23
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Wraps a dockerfile to allow it to be easily tested
|
2
|
+
class Dockerfile
|
3
|
+
attr_reader :path
|
4
|
+
|
5
|
+
def initialize(name)
|
6
|
+
@path = Pathname.new(File.expand_path("../../../docker/#{name.downcase}/Dockerfile", __FILE__))
|
7
|
+
end
|
8
|
+
|
9
|
+
def include_env?(name, value)
|
10
|
+
path.read =~ /ENV #{name} (#{value}|"#{value}")/
|
11
|
+
end
|
12
|
+
end
|
@@ -5,7 +5,7 @@ shared_examples_for 'language' do
|
|
5
5
|
it 'returns a list of linters which reference this language' do
|
6
6
|
language.linters.each do |linter|
|
7
7
|
expect(linter.languages).to include(language),
|
8
|
-
|
8
|
+
"expected #{linter.name} to reference #{language.name} as one of it's languages"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|