lint_trap 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -1
- data/lib/lint_trap/container/base.rb +1 -0
- data/lib/lint_trap/language/base.rb +8 -6
- data/lib/lint_trap/language/coffeescript.rb +0 -3
- data/lib/lint_trap/language/cpp.rb +0 -4
- data/lib/lint_trap/language/css.rb +0 -3
- data/lib/lint_trap/language/go.rb +0 -3
- data/lib/lint_trap/language/java.rb +0 -3
- data/lib/lint_trap/language/javascript.rb +0 -3
- data/lib/lint_trap/language/json.rb +0 -3
- data/lib/lint_trap/language/python.rb +0 -3
- data/lib/lint_trap/language/ruby.rb +0 -3
- data/lib/lint_trap/language/scss.rb +0 -3
- data/lib/lint_trap/language/unknown.rb +1 -11
- data/lib/lint_trap/language.rb +6 -19
- data/lib/lint_trap/linter/base.rb +21 -19
- data/lib/lint_trap/linter/checkstyle.rb +0 -4
- data/lib/lint_trap/linter/coffeelint.rb +0 -4
- data/lib/lint_trap/linter/cppcheck.rb +0 -4
- data/lib/lint_trap/linter/csslint.rb +0 -8
- data/lib/lint_trap/linter/golint.rb +0 -8
- data/lib/lint_trap/linter/jshint.rb +0 -4
- data/lib/lint_trap/linter/jsonlint.rb +0 -4
- data/lib/lint_trap/linter/pylint.rb +0 -4
- data/lib/lint_trap/linter/rubocop.rb +0 -4
- data/lib/lint_trap/linter/scsslint.rb +0 -4
- data/lib/lint_trap/linter/unknown.rb +2 -9
- data/lib/lint_trap/linter.rb +20 -26
- data/lib/lint_trap/parser/base.rb +5 -9
- data/lib/lint_trap/parser/line.rb +6 -6
- data/lib/lint_trap/parser.rb +16 -0
- data/lib/lint_trap/registerable.rb +20 -0
- data/lib/lint_trap/registry.rb +29 -0
- data/lib/lint_trap/version.rb +2 -1
- data/lib/lint_trap.rb +1 -0
- data/lint_trap.gemspec +2 -2
- data/spec/integration/base_spec.rb +5 -1
- data/spec/integration/checkstyle_spec.rb +1 -1
- data/spec/integration/coffeelint_spec.rb +1 -1
- data/spec/integration/cppcheck_spec.rb +1 -1
- data/spec/integration/csslint_spec.rb +1 -1
- data/spec/integration/golint_spec.rb +1 -1
- data/spec/integration/jshint_spec.rb +1 -1
- data/spec/integration/jsonlint_spec.rb +1 -1
- data/spec/integration/pylint_spec.rb +1 -1
- data/spec/integration/rubocop_spec.rb +1 -1
- data/spec/integration/scsslint_spec.rb +1 -1
- data/spec/language/coffeescript_spec.rb +1 -2
- data/spec/language/cpp_spec.rb +1 -2
- data/spec/language/css_spec.rb +1 -2
- data/spec/language/go_spec.rb +1 -2
- data/spec/language/java_spec.rb +1 -2
- data/spec/language/javascript_spec.rb +1 -2
- data/spec/language/json_spec.rb +1 -2
- data/spec/language/python_spec.rb +1 -2
- data/spec/language/ruby_spec.rb +1 -2
- data/spec/language/scss_spec.rb +1 -2
- data/spec/language/unknown_spec.rb +1 -11
- data/spec/language_spec.rb +21 -2
- data/spec/linter/checkstyle_spec.rb +1 -1
- data/spec/linter/coffeelint_spec.rb +1 -1
- data/spec/linter/cppcheck_spec.rb +1 -1
- data/spec/linter/csslint_spec.rb +1 -1
- data/spec/linter/golint_spec.rb +1 -1
- data/spec/linter/jshint_spec.rb +1 -1
- data/spec/linter/jsonlint_spec.rb +1 -1
- data/spec/linter/pylint_spec.rb +1 -1
- data/spec/linter/rubocop_spec.rb +1 -1
- data/spec/linter/scsslint_spec.rb +1 -1
- data/spec/linter/unknown_spec.rb +1 -0
- data/spec/linter_spec.rb +1 -1
- data/spec/parser/base_spec.rb +3 -2
- data/spec/parser/csslint_spec.rb +2 -2
- data/spec/parser/line_spec.rb +3 -2
- data/spec/parser/standard_spec.rb +2 -2
- data/spec/parser/vim_quickfix_spec.rb +2 -2
- data/spec/registry_spec.rb +52 -0
- data/spec/support/examples/linter.rb +2 -1
- metadata +7 -2
@@ -0,0 +1,29 @@
|
|
1
|
+
module LintTrap
|
2
|
+
# Allow registration and discovery of plugins
|
3
|
+
class Registry
|
4
|
+
def initialize
|
5
|
+
@registry = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def default(thing_class)
|
9
|
+
@registry.default = thing_class.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def register(thing_class)
|
13
|
+
thing = thing_class.new
|
14
|
+
registry[thing.name] = thing
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(name)
|
18
|
+
registry[name]
|
19
|
+
end
|
20
|
+
|
21
|
+
def all
|
22
|
+
registry.values
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
attr_reader :registry
|
28
|
+
end
|
29
|
+
end
|
data/lib/lint_trap/version.rb
CHANGED
data/lib/lint_trap.rb
CHANGED
data/lint_trap.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(
|
18
|
-
spec.test_files = spec.files.grep(
|
17
|
+
spec.executables = spec.files.grep(/^bin\//){|f| File.basename(f)}
|
18
|
+
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'github-linguist', '~> 4.2'
|
@@ -13,6 +13,10 @@ describe LintTrap::Linter::Base do
|
|
13
13
|
def flags(_container, _options)
|
14
14
|
[]
|
15
15
|
end
|
16
|
+
|
17
|
+
def parser
|
18
|
+
LintTrap::Parser.find('Standard')
|
19
|
+
end
|
16
20
|
end.new
|
17
21
|
end
|
18
22
|
|
@@ -22,7 +26,7 @@ describe LintTrap::Linter::Base do
|
|
22
26
|
|
23
27
|
it 'raises an error with console output' do
|
24
28
|
expect{|b| linter.lint([file], container, options, &b)}.to raise_error(
|
25
|
-
|
29
|
+
described_class::LintError,
|
26
30
|
start_with(
|
27
31
|
'An error occurred while running `docker run'
|
28
32
|
)
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::CheckStyle do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('CheckStyle')}
|
7
7
|
|
8
8
|
describe '#lint' do
|
9
9
|
context 'when linting a bad file' do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::CoffeeLint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('CoffeeLint')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::CPPCheck do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('CPPCheck')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::CSSLint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('CSSLint')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::GoLint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('GoLint')}
|
7
7
|
|
8
8
|
describe '#lint' do
|
9
9
|
context 'when linting a bad file' do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::JSHint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('JSHint')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::JSONLint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('JSONLint')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::PyLint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('PyLint')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::RuboCop do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('RuboCop')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Linter::SCSSLint do
|
4
4
|
let(:container){LintTrap::Container::Docker.new(linter.image_version, fixture_path, remove_container: ENV['CI'].nil?)}
|
5
5
|
let(:options){{}}
|
6
|
-
subject(:linter){
|
6
|
+
subject(:linter){LintTrap::Linter.find('SCSSLint')}
|
7
7
|
|
8
8
|
describe '#version' do
|
9
9
|
subject(:dockerfile){Dockerfile.new(linter.name)}
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::CoffeeScript do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('CoffeeScript')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/cpp_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::CPP do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('C++')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/css_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::CSS do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('CSS')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/go_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::Go do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('Go')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/java_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::Java do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('Java')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::JavaScript do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('JavaScript')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/json_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::JSON do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('JSON')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::Python do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('Python')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/ruby_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::Ruby do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('Ruby')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
data/spec/language/scss_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language::SCSS do
|
4
|
-
subject(:language){
|
4
|
+
subject(:language){LintTrap::Language.find('SCSS')}
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
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}
|
11
10
|
end
|
@@ -5,16 +5,6 @@ describe LintTrap::Language::Unknown do
|
|
5
5
|
|
6
6
|
it_behaves_like 'language'
|
7
7
|
|
8
|
-
|
9
|
-
its(:name){is_expected.to eq('Unknown')}
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'when a name is passed' do
|
13
|
-
subject(:language){described_class.new('Huh')}
|
14
|
-
|
15
|
-
its(:name){is_expected.to eq('Huh')}
|
16
|
-
end
|
17
|
-
|
8
|
+
its(:name){is_expected.to eq('Unknown')}
|
18
9
|
its(:linters){is_expected.to eq([LintTrap::Linter::Unknown.new])}
|
19
|
-
it{is_expected.to_not be_known}
|
20
10
|
end
|
data/spec/language_spec.rb
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LintTrap::Language do
|
4
|
+
describe '.all' do
|
5
|
+
subject(:languages){described_class.all}
|
6
|
+
|
7
|
+
it do
|
8
|
+
is_expected.to match([
|
9
|
+
be_a(described_class::CoffeeScript),
|
10
|
+
be_a(described_class::CPP),
|
11
|
+
be_a(described_class::CSS),
|
12
|
+
be_a(described_class::Go),
|
13
|
+
be_a(described_class::Java),
|
14
|
+
be_a(described_class::JavaScript),
|
15
|
+
be_a(described_class::JSON),
|
16
|
+
be_a(described_class::Python),
|
17
|
+
be_a(described_class::Ruby),
|
18
|
+
be_a(described_class::SCSS)
|
19
|
+
])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
4
23
|
describe '.detect' do
|
5
24
|
subject(:language){described_class.detect(file)}
|
6
25
|
|
@@ -67,7 +86,7 @@ describe LintTrap::Language do
|
|
67
86
|
context 'when given an unknown language file' do
|
68
87
|
let(:file){fixture_path('lint.txt')}
|
69
88
|
|
70
|
-
it{is_expected.to eq(described_class::Unknown.new
|
89
|
+
it{is_expected.to eq(described_class::Unknown.new)}
|
71
90
|
end
|
72
91
|
|
73
92
|
context 'when given a known language file that is empty' do
|
@@ -144,7 +163,7 @@ describe LintTrap::Language do
|
|
144
163
|
context 'when given an invalid language' do
|
145
164
|
let(:language_name){'invalid language'}
|
146
165
|
|
147
|
-
it{is_expected.to eq(described_class::Unknown.new
|
166
|
+
it{is_expected.to eq(described_class::Unknown.new)}
|
148
167
|
end
|
149
168
|
end
|
150
169
|
end
|
@@ -5,7 +5,7 @@ describe LintTrap::Linter::CheckStyle do
|
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(Good.java bad.java)}
|
7
7
|
let(:command){instance_double(LintTrap::Command)}
|
8
|
-
subject(:linter){
|
8
|
+
subject(:linter){LintTrap::Linter.find('CheckStyle')}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
@@ -4,7 +4,7 @@ describe LintTrap::Linter::CoffeeLint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.coffee bad.coffee)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('CoffeeLint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
@@ -4,7 +4,7 @@ describe LintTrap::Linter::CPPCheck do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.cpp bad.cpp)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('CPPCheck')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
data/spec/linter/csslint_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe LintTrap::Linter::CSSLint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.css bad.css)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('CSSLint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
data/spec/linter/golint_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe LintTrap::Linter::GoLint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.go bad.go)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('GoLint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
data/spec/linter/jshint_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe LintTrap::Linter::JSHint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.js bad.js)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('JSHint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
@@ -4,7 +4,7 @@ describe LintTrap::Linter::JSONLint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.go bad.go)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('JSONLint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
data/spec/linter/pylint_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe LintTrap::Linter::PyLint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.py bad.py)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('PyLint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
data/spec/linter/rubocop_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe LintTrap::Linter::RuboCop do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.rb bad.rb)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('RuboCop')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
@@ -4,7 +4,7 @@ describe LintTrap::Linter::SCSSLint do
|
|
4
4
|
let(:container){LintTrap::Container::Fake.new}
|
5
5
|
let(:options){{}}
|
6
6
|
let(:files){%w(good.scss bad.scss)}
|
7
|
-
subject(:linter){
|
7
|
+
subject(:linter){LintTrap::Linter.find('SCSSLint')}
|
8
8
|
let(:command){instance_double(LintTrap::Command)}
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
data/spec/linter/unknown_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe LintTrap::Linter::Unknown do
|
|
9
9
|
|
10
10
|
it_behaves_like 'linter'
|
11
11
|
|
12
|
+
its(:name){is_expected.to eq('Unknown')}
|
12
13
|
its(:languages){is_expected.to eq([LintTrap::Language::Unknown.new])}
|
13
14
|
its(:version){is_expected.to eq(LintTrap::VERSION)}
|
14
15
|
its(:image){is_expected.to eq('lintci/unknown')}
|
data/spec/linter_spec.rb
CHANGED
data/spec/parser/base_spec.rb
CHANGED
@@ -3,11 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Parser::Base do
|
4
4
|
let(:image){LintTrap::Linter::RuboCop.new.image_version}
|
5
5
|
let(:container){LintTrap::Container::Docker.new(image, fixture_path, remove_container: ENV['CI'].nil?)}
|
6
|
-
|
6
|
+
let(:io){StringIO.new}
|
7
|
+
subject(:parser){Class.new(described_class).new}
|
7
8
|
|
8
9
|
describe '#parse' do
|
9
10
|
it 'raises an error if not overriden' do
|
10
|
-
expect{parser.parse}.to raise_error(NotImplementedError, 'Must implement parse.')
|
11
|
+
expect{parser.parse(io, container)}.to raise_error(NotImplementedError, 'Must implement parse.')
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/spec/parser/csslint_spec.rb
CHANGED
@@ -7,11 +7,11 @@ describe LintTrap::Parser::CSSLint do
|
|
7
7
|
end
|
8
8
|
let(:io){StringIO.new(parser_output)}
|
9
9
|
let(:container){LintTrap::Container::Fake.new}
|
10
|
-
subject(:parser){described_class.new
|
10
|
+
subject(:parser){described_class.new}
|
11
11
|
|
12
12
|
describe '.parse' do
|
13
13
|
it 'parses violations from io' do
|
14
|
-
expect{|b| @result = parser.parse(&b)}.to yield_successive_args(
|
14
|
+
expect{|b| @result = parser.parse(io, container, &b)}.to yield_successive_args(
|
15
15
|
file: 'bad.css',
|
16
16
|
line: '2',
|
17
17
|
column: '5',
|
data/spec/parser/line_spec.rb
CHANGED
@@ -3,11 +3,12 @@ require 'spec_helper'
|
|
3
3
|
describe LintTrap::Parser::Line do
|
4
4
|
let(:image){LintTrap::Linter::RuboCop.new.image_version}
|
5
5
|
let(:container){LintTrap::Container::Docker.new(image, fixture_path, remove_container: ENV['CI'].nil?)}
|
6
|
-
|
6
|
+
let(:io){StringIO.new('violation')}
|
7
|
+
subject(:parser){Class.new(described_class).new}
|
7
8
|
|
8
9
|
describe '#parse' do
|
9
10
|
it 'raises an error if #violation_regex not overriden' do
|
10
|
-
expect{parser.parse}.to raise_error(NotImplementedError, 'Must implement violation_regex.')
|
11
|
+
expect{parser.parse(io, container)}.to raise_error(NotImplementedError, 'Must implement violation_regex.')
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -12,11 +12,11 @@ describe LintTrap::Parser::Standard do
|
|
12
12
|
end
|
13
13
|
let(:io){StringIO.new(parser_output)}
|
14
14
|
let(:container){LintTrap::Container::Fake.new}
|
15
|
-
subject(:parser){described_class.new
|
15
|
+
subject(:parser){described_class.new}
|
16
16
|
|
17
17
|
describe '.parse' do
|
18
18
|
it 'parses violations from io' do
|
19
|
-
expect{|b| @result = parser.parse(&b)}.to yield_successive_args(
|
19
|
+
expect{|b| @result = parser.parse(io, container, &b)}.to yield_successive_args(
|
20
20
|
{
|
21
21
|
file: 'bad.java',
|
22
22
|
line: '1',
|
@@ -6,11 +6,11 @@ describe LintTrap::Parser::VimQuickfix do
|
|
6
6
|
end
|
7
7
|
let(:io){StringIO.new(parser_output)}
|
8
8
|
let(:container){LintTrap::Container::Fake.new}
|
9
|
-
subject(:parser){described_class.new
|
9
|
+
subject(:parser){described_class.new}
|
10
10
|
|
11
11
|
describe '#parse' do
|
12
12
|
it 'parses violations from io' do
|
13
|
-
expect{|b| @result = parser.parse(&b)}.to yield_successive_args(
|
13
|
+
expect{|b| @result = parser.parse(io, container, &b)}.to yield_successive_args(
|
14
14
|
file: 'bad.go',
|
15
15
|
line: '5',
|
16
16
|
column: '1',
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Registry do
|
4
|
+
let(:a) do
|
5
|
+
Class.new do
|
6
|
+
def name
|
7
|
+
'a'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
let(:b) do
|
12
|
+
Class.new do
|
13
|
+
def name
|
14
|
+
'b'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
subject(:registry){described_class.new}
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
registry.register(a)
|
23
|
+
registry.register(b)
|
24
|
+
registry.default(b)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#all' do
|
28
|
+
subject(:all){registry.all}
|
29
|
+
|
30
|
+
it{is_expected.to match([be_a(a), be_a(b)])}
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#find' do
|
34
|
+
context 'when searching for a' do
|
35
|
+
it 'finds an a' do
|
36
|
+
expect(registry.find('a')).to be_a(a)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when searching for b' do
|
41
|
+
it 'finds a b' do
|
42
|
+
expect(registry.find('b')).to be_a(b)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when searching for an unregistered value' do
|
47
|
+
it 'finds the default' do
|
48
|
+
expect(registry.find('c')).to be_a(b)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -4,7 +4,8 @@ shared_examples_for 'linter' do
|
|
4
4
|
describe '#languages' do
|
5
5
|
it 'returns a list of languages which reference this linter' do
|
6
6
|
linter.languages.each do |language|
|
7
|
-
expect(language.linters).to include(linter),
|
7
|
+
expect(language.linters).to include(linter),
|
8
|
+
"expected #{language.name} to reference #{linter.name} as one of it's linters"
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|