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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/Rakefile +32 -22
  4. data/circle.yml +0 -2
  5. data/config/checkstyle/checkstyle_logger-6.6-all.jar +0 -0
  6. data/config/checkstyle/sun_checks.xml +2 -1
  7. data/docker/checkstyle/Dockerfile +19 -0
  8. data/docker/coffeelint/Dockerfile +21 -0
  9. data/docker/cppcheck/Dockerfile +24 -0
  10. data/docker/csslint/Dockerfile +21 -0
  11. data/docker/golint/Dockerfile +19 -0
  12. data/docker/jshint/Dockerfile +21 -0
  13. data/docker/jsonlint/Dockerfile +21 -0
  14. data/docker/pylint/Dockerfile +24 -0
  15. data/docker/rubocop/Dockerfile +21 -0
  16. data/docker/scsslint/Dockerfile +21 -0
  17. data/lib/lint_trap/command.rb +2 -3
  18. data/lib/lint_trap/container/base.rb +10 -3
  19. data/lib/lint_trap/container/docker.rb +16 -3
  20. data/lib/lint_trap/container/fake.rb +3 -0
  21. data/lib/lint_trap/execution_error.rb +12 -0
  22. data/lib/lint_trap/linter/base.rb +29 -18
  23. data/lib/lint_trap/linter/checkstyle.rb +12 -5
  24. data/lib/lint_trap/linter/coffeelint.rb +6 -2
  25. data/lib/lint_trap/linter/cppcheck.rb +5 -1
  26. data/lib/lint_trap/linter/csslint.rb +6 -2
  27. data/lib/lint_trap/linter/golint.rb +6 -2
  28. data/lib/lint_trap/linter/jshint.rb +6 -2
  29. data/lib/lint_trap/linter/jsonlint.rb +6 -2
  30. data/lib/lint_trap/linter/pylint.rb +5 -1
  31. data/lib/lint_trap/linter/rubocop.rb +6 -2
  32. data/lib/lint_trap/linter/scsslint.rb +7 -3
  33. data/lib/lint_trap/linter/unknown.rb +4 -0
  34. data/lib/lint_trap/linter.rb +4 -0
  35. data/lib/lint_trap/parser/base.rb +1 -1
  36. data/lib/lint_trap/parser/line.rb +12 -6
  37. data/lib/lint_trap/version.rb +1 -1
  38. data/lint_trap.gemspec +15 -14
  39. data/spec/command_spec.rb +8 -5
  40. data/spec/container/base_spec.rb +31 -0
  41. data/spec/container/docker_spec.rb +27 -7
  42. data/spec/execution_error_spec.rb +11 -0
  43. data/spec/integration/base_spec.rb +33 -0
  44. data/spec/integration/checkstyle_spec.rb +1 -1
  45. data/spec/integration/coffeelint_spec.rb +16 -10
  46. data/spec/integration/cppcheck_spec.rb +9 -1
  47. data/spec/integration/csslint_spec.rb +16 -10
  48. data/spec/integration/golint_spec.rb +8 -10
  49. data/spec/integration/jshint_spec.rb +9 -1
  50. data/spec/integration/jsonlint_spec.rb +9 -1
  51. data/spec/integration/pylint_spec.rb +9 -1
  52. data/spec/integration/rubocop_spec.rb +9 -1
  53. data/spec/integration/scsslint_spec.rb +16 -10
  54. data/spec/language/coffeescript_spec.rb +1 -0
  55. data/spec/language/cpp_spec.rb +1 -0
  56. data/spec/language/css_spec.rb +1 -0
  57. data/spec/language/go_spec.rb +1 -0
  58. data/spec/language/java_spec.rb +1 -0
  59. data/spec/language/javascript_spec.rb +1 -0
  60. data/spec/language/json_spec.rb +1 -0
  61. data/spec/language/python_spec.rb +1 -0
  62. data/spec/language/ruby_spec.rb +1 -0
  63. data/spec/language/scss_spec.rb +1 -0
  64. data/spec/language/unknown_spec.rb +1 -0
  65. data/spec/linter/base_spec.rb +24 -0
  66. data/spec/linter/checkstyle_spec.rb +8 -4
  67. data/spec/linter/coffeelint_spec.rb +5 -2
  68. data/spec/linter/cppcheck_spec.rb +4 -1
  69. data/spec/linter/csslint_spec.rb +5 -2
  70. data/spec/linter/golint_spec.rb +4 -1
  71. data/spec/linter/jshint_spec.rb +5 -2
  72. data/spec/linter/jsonlint_spec.rb +4 -1
  73. data/spec/linter/pylint_spec.rb +5 -2
  74. data/spec/linter/rubocop_spec.rb +5 -2
  75. data/spec/linter/scsslint_spec.rb +5 -2
  76. data/spec/linter/unknown_spec.rb +3 -0
  77. data/spec/linter_spec.rb +20 -1
  78. data/spec/parser/base_spec.rb +13 -0
  79. data/spec/parser/csslint_spec.rb +3 -1
  80. data/spec/parser/line_spec.rb +13 -0
  81. data/spec/parser/standard_spec.rb +4 -2
  82. data/spec/parser/vim_quickfix_spec.rb +10 -10
  83. data/spec/spec_helper.rb +15 -0
  84. data/spec/support/dockerfile.rb +12 -0
  85. data/spec/support/examples/language.rb +1 -1
  86. metadata +43 -4
  87. 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('lintci/spin_cycle:latest', fixture_path)}
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
- file: file,
16
- line: '2',
17
- column: '3',
18
- length: '12',
19
- rule: 'BorderZero',
20
- severity: 'warning',
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
@@ -7,4 +7,5 @@ describe LintTrap::Language::CoffeeScript do
7
7
 
8
8
  its(:name){is_expected.to eq('CoffeeScript')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CoffeeLint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::CPP do
7
7
 
8
8
  its(:name){is_expected.to eq('C++')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CPPCheck.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::CSS do
7
7
 
8
8
  its(:name){is_expected.to eq('CSS')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CSSLint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::Go do
7
7
 
8
8
  its(:name){is_expected.to eq('Go')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::GoLint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::Java do
7
7
 
8
8
  its(:name){is_expected.to eq('Java')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::CheckStyle.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::JavaScript do
7
7
 
8
8
  its(:name){is_expected.to eq('JavaScript')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::JSHint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::JSON do
7
7
 
8
8
  its(:name){is_expected.to eq('JSON')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::JSONLint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::Python do
7
7
 
8
8
  its(:name){is_expected.to eq('Python')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::PyLint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::Ruby do
7
7
 
8
8
  its(:name){is_expected.to eq('Ruby')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::RuboCop.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -7,4 +7,5 @@ describe LintTrap::Language::SCSS do
7
7
 
8
8
  its(:name){is_expected.to eq('SCSS')}
9
9
  its(:linters){is_expected.to eq([LintTrap::Linter::SCSSLint.new])}
10
+ it{is_expected.to be_known}
10
11
  end
@@ -16,4 +16,5 @@ describe LintTrap::Language::Unknown do
16
16
  end
17
17
 
18
18
  its(:linters){is_expected.to eq([LintTrap::Linter::Unknown.new])}
19
+ it{is_expected.to_not be_known}
19
20
  end
@@ -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(described_class::JAR),
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(described_class::JAR),
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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(:language){described_class.find(linter_name)}
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
@@ -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
- "bad.java:1:0::com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck:error:"\
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
- file: 'bad.go',
16
- line: '5',
17
- column: '1',
18
- length: nil,
19
- rule: nil,
20
- severity: nil,
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
- "expected #{linter.name} to reference #{language.name} as one of it's languages"
8
+ "expected #{linter.name} to reference #{language.name} as one of it's languages"
9
9
  end
10
10
  end
11
11
  end