lint_trap 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +97 -0
- data/Dockerfile +222 -0
- data/Gemfile +2 -0
- data/Rakefile +45 -0
- data/circle.yml +22 -0
- data/config/checkstyle/checkstyle_logger-all.jar +0 -0
- data/config/checkstyle/sun_checks.xml +177 -0
- data/config/coffeelint/lint_trap.coffee +12 -0
- data/config/jshint/formatter.js +22 -0
- data/config/rubocop/formatter.rb +22 -0
- data/config/scsslint/scsslint +34 -0
- data/lib/lint_trap/command.rb +39 -0
- data/lib/lint_trap/container/base.rb +30 -0
- data/lib/lint_trap/container/docker.rb +46 -0
- data/lib/lint_trap/container/fake.rb +28 -0
- data/lib/lint_trap/language/base.rb +18 -0
- data/lib/lint_trap/language/coffeescript.rb +13 -0
- data/lib/lint_trap/language/cpp.rb +17 -0
- data/lib/lint_trap/language/css.rb +13 -0
- data/lib/lint_trap/language/go.rb +13 -0
- data/lib/lint_trap/language/java.rb +13 -0
- data/lib/lint_trap/language/javascript.rb +13 -0
- data/lib/lint_trap/language/json.rb +13 -0
- data/lib/lint_trap/language/python.rb +13 -0
- data/lib/lint_trap/language/ruby.rb +13 -0
- data/lib/lint_trap/language/scss.rb +13 -0
- data/lib/lint_trap/language.rb +50 -0
- data/lib/lint_trap/linter/base.rb +58 -0
- data/lib/lint_trap/linter/checkstyle.rb +24 -0
- data/lib/lint_trap/linter/coffeelint.rb +21 -0
- data/lib/lint_trap/linter/cppcheck.rb +18 -0
- data/lib/lint_trap/linter/csslint.rb +23 -0
- data/lib/lint_trap/linter/golint.rb +19 -0
- data/lib/lint_trap/linter/jshint.rb +20 -0
- data/lib/lint_trap/linter/jsonlint.rb +18 -0
- data/lib/lint_trap/linter/pylint.rb +19 -0
- data/lib/lint_trap/linter/rubocop.rb +22 -0
- data/lib/lint_trap/linter/scsslint.rb +22 -0
- data/lib/lint_trap/linter.rb +42 -0
- data/lib/lint_trap/{parsers/base_parser.rb → parser/base.rb} +8 -9
- data/lib/lint_trap/{parsers/csslint_parser.rb → parser/csslint.rb} +4 -5
- data/lib/lint_trap/{parsers/line_parser.rb → parser/line.rb} +14 -5
- data/lib/lint_trap/parser/standard.rb +22 -0
- data/lib/lint_trap/parser/vim_quickfix.rb +19 -0
- data/lib/lint_trap/version.rb +1 -1
- data/lib/lint_trap.rb +5 -14
- data/lint_trap.gemspec +3 -0
- data/spec/command_spec.rb +38 -0
- data/spec/container/docker_spec.rb +34 -0
- data/spec/container/fake_spec.rb +29 -0
- data/spec/fixtures/Good.java +6 -0
- data/spec/fixtures/bad.coffee +1 -0
- data/spec/fixtures/bad.cpp +5 -0
- data/spec/fixtures/bad.css +4 -0
- data/spec/fixtures/bad.go +7 -0
- data/spec/fixtures/bad.java +3 -0
- data/spec/fixtures/bad.js +3 -0
- data/spec/fixtures/bad.json +4 -0
- data/spec/fixtures/bad.py +2 -0
- data/spec/fixtures/bad.rb +4 -0
- data/spec/fixtures/bad.scss +3 -0
- data/spec/fixtures/good.coffee +1 -0
- data/spec/fixtures/good.cpp +4 -0
- data/spec/fixtures/good.css +3 -0
- data/spec/fixtures/good.go +7 -0
- data/spec/fixtures/good.js +5 -0
- data/spec/fixtures/good.json +4 -0
- data/spec/fixtures/good.py +6 -0
- data/spec/fixtures/good.rb +5 -0
- data/spec/fixtures/good.scss +3 -0
- data/spec/fixtures/lint.txt +1 -0
- data/spec/integration/checkstyle_spec.rb +52 -0
- data/spec/integration/coffeelint_spec.rb +44 -0
- data/spec/integration/cppcheck_spec.rb +60 -0
- data/spec/integration/csslint_spec.rb +44 -0
- data/spec/integration/golint_spec.rb +44 -0
- data/spec/integration/jshint_spec.rb +70 -0
- data/spec/integration/jsonlint_spec.rb +60 -0
- data/spec/integration/pylint_spec.rb +51 -0
- data/spec/integration/rubocop_spec.rb +52 -0
- data/spec/integration/scsslint_spec.rb +44 -0
- data/spec/language/coffeescript_spec.rb +8 -0
- data/spec/language/cpp_spec.rb +8 -0
- data/spec/language/css_spec.rb +8 -0
- data/spec/language/go_spec.rb +8 -0
- data/spec/language/java_spec.rb +8 -0
- data/spec/language/javascript_spec.rb +8 -0
- data/spec/language/json_spec.rb +8 -0
- data/spec/language/python_spec.rb +8 -0
- data/spec/language/ruby_spec.rb +8 -0
- data/spec/language/scss_spec.rb +8 -0
- data/spec/language_spec.rb +143 -0
- data/spec/lint_trap_spec.rb +0 -16
- data/spec/linter/checkstyle_spec.rb +45 -0
- data/spec/linter/coffeelint_spec.rb +46 -0
- data/spec/linter/cppcheck_spec.rb +26 -0
- data/spec/linter/csslint_spec.rb +44 -0
- data/spec/linter/golint_spec.rb +22 -0
- data/spec/linter/jshint_spec.rb +44 -0
- data/spec/linter/jsonlint_spec.rb +22 -0
- data/spec/linter/pylint_spec.rb +46 -0
- data/spec/linter/rubocop_spec.rb +48 -0
- data/spec/linter/scsslint_spec.rb +44 -0
- data/spec/linter_spec.rb +67 -0
- data/spec/parser/csslint_spec.rb +25 -0
- data/spec/{parsers/standard_parser_spec.rb → parser/standard_spec.rb} +4 -3
- data/spec/{parsers/vim_quickfix_parser_spec.rb → parser/vim_quickfix_spec.rb} +5 -4
- data/spec/spec_helper.rb +8 -0
- data/spec/support/fixture_file_helper.rb +8 -0
- metadata +193 -18
- data/lib/lint_trap/parser_factory.rb +0 -32
- data/lib/lint_trap/parsers/null_parser.rb +0 -11
- data/lib/lint_trap/parsers/standard_parser.rb +0 -23
- data/lib/lint_trap/parsers/vim_quickfix_parser.rb +0 -20
- data/spec/parser_factory_spec.rb +0 -17
- data/spec/parsers/csslint_parser_spec.rb +0 -26
@@ -1,19 +1,18 @@
|
|
1
1
|
module LintTrap
|
2
|
-
module
|
3
|
-
class
|
4
|
-
|
5
|
-
def parse(io)
|
6
|
-
new(io).parse(&Proc.new)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(io)
|
2
|
+
module Parser
|
3
|
+
class Base
|
4
|
+
def initialize(io, container)
|
11
5
|
@io = io
|
6
|
+
@container = container
|
12
7
|
end
|
13
8
|
|
14
9
|
def parse
|
15
10
|
raise NotImplementedError, "Subclass #{self.class.name} must implement parse."
|
16
11
|
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
attr_reader :container, :io
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'line'
|
2
2
|
|
3
3
|
module LintTrap
|
4
|
-
module
|
5
|
-
# Handles parsing
|
6
|
-
class
|
7
|
-
|
4
|
+
module Parser
|
5
|
+
# Handles parsing LintTrap standard format
|
6
|
+
class CSSLint < Line
|
8
7
|
private
|
9
8
|
|
10
9
|
def violation_regex
|
@@ -1,11 +1,12 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'base'
|
2
2
|
|
3
3
|
module LintTrap
|
4
|
-
module
|
4
|
+
module Parser
|
5
5
|
# Handles parsing line by line with regex
|
6
|
-
class
|
6
|
+
class Line < Base
|
7
7
|
def parse
|
8
|
-
|
8
|
+
io.each_line do |line|
|
9
|
+
puts line if ENV['DEBUG_LINTING']
|
9
10
|
next unless (violation = parse_line(line))
|
10
11
|
|
11
12
|
yield violation
|
@@ -17,13 +18,15 @@ module LintTrap
|
|
17
18
|
def parse_line(line)
|
18
19
|
return unless (match = line.match(violation_regex))
|
19
20
|
|
20
|
-
violation_fields.each_with_object({}) do |field, violation|
|
21
|
+
violation = violation_fields.each_with_object({}) do |field, violation|
|
21
22
|
violation[field.to_sym] = if match.names.include?(field) && !match[field].empty?
|
22
23
|
match[field]
|
23
24
|
else
|
24
25
|
nil
|
25
26
|
end
|
26
27
|
end
|
28
|
+
|
29
|
+
standardize(violation)
|
27
30
|
end
|
28
31
|
|
29
32
|
def violation_fields
|
@@ -33,6 +36,12 @@ module LintTrap
|
|
33
36
|
def violation_regex
|
34
37
|
raise NotImplementedError, "Subclass #{self.class.name} must implement violation_regex."
|
35
38
|
end
|
39
|
+
|
40
|
+
def standardize(violation)
|
41
|
+
violation[:file] = container.local_path(violation[:file])
|
42
|
+
|
43
|
+
violation
|
44
|
+
end
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'line'
|
2
|
+
|
3
|
+
module LintTrap
|
4
|
+
module Parser
|
5
|
+
# Handles parsing LintTrap standard format
|
6
|
+
class Standard < Line
|
7
|
+
private
|
8
|
+
|
9
|
+
def violation_regex
|
10
|
+
/
|
11
|
+
(?<file>[^:]+):
|
12
|
+
(?<line>\d*):
|
13
|
+
(?<column>\d*):
|
14
|
+
(?<length>\d*):
|
15
|
+
(?<rule>[^:]*):
|
16
|
+
(?<severity>[^:]*):
|
17
|
+
(?<message>.+)
|
18
|
+
/x
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'line'
|
2
|
+
|
3
|
+
module LintTrap
|
4
|
+
module Parser
|
5
|
+
# Handles parsing LintTrap standard format
|
6
|
+
class VimQuickfix < Line
|
7
|
+
private
|
8
|
+
|
9
|
+
def violation_regex
|
10
|
+
/
|
11
|
+
(?<file>[^:]+):
|
12
|
+
(?<line>\d*):
|
13
|
+
(?<column>\d*):\s*
|
14
|
+
(?<message>.+)
|
15
|
+
/x
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/lint_trap/version.rb
CHANGED
data/lib/lint_trap.rb
CHANGED
@@ -1,14 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def parse(linter, io, parser_name = nil)
|
8
|
-
parser = ParserFactory.parser_for(parser_name)
|
9
|
-
parser = ParserFactory.parser_for(linter) if parser_name.nil?
|
10
|
-
|
11
|
-
parser.parse(io, &Proc.new)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
require_relative 'lint_trap/version'
|
2
|
+
require_relative 'lint_trap/language'
|
3
|
+
require_relative 'lint_trap/linter'
|
4
|
+
require_relative 'lint_trap/container/docker'
|
5
|
+
require_relative 'lint_trap/container/fake'
|
data/lint_trap.gemspec
CHANGED
@@ -18,8 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_runtime_dependency 'github-linguist', '~> 4.2'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
25
|
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "rspec-its"
|
24
27
|
spec.add_development_dependency "pry-byebug"
|
25
28
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Command do
|
4
|
+
let(:file){'fake file.txt'}
|
5
|
+
let(:command){described_class.new('cat', %w(-b), [file])}
|
6
|
+
let(:container){LintTrap::Container::Fake.new}
|
7
|
+
|
8
|
+
describe '#run' do
|
9
|
+
let(:file){File.expand_path('../fixtures/lint.txt', __FILE__)}
|
10
|
+
|
11
|
+
it 'generates the expected output' do
|
12
|
+
command.run(container) do |io|
|
13
|
+
expect(io.read).to eq(" 1\tlint\n")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#command/#to_s' do
|
19
|
+
context 'with fake container' do
|
20
|
+
it 'generates a bare executable command' do
|
21
|
+
expect(command.to_s).to eq('cat -b fake\ file.txt 2>&1')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with docker container' do
|
26
|
+
let(:file){fixture_path('lint.txt')}
|
27
|
+
let(:container){LintTrap::Container::Docker.new('lint/runner', fixture_path)}
|
28
|
+
|
29
|
+
it 'generates a wrapped executable command' do
|
30
|
+
expect(command.to_s(container)).to eq(
|
31
|
+
"docker run --privileged=false -v #{LintTrap::Container::Base::LOCAL_CONFIG_PATH}:/opt/lint_trap/config "\
|
32
|
+
"-v #{fixture_path}:/home/spin_cycle --workdir=/home/spin_cycle --user=spin_cycle lint/runner "\
|
33
|
+
'cat -b /home/spin_cycle/lint.txt 2>&1'
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Container::Docker do
|
4
|
+
subject(:container){described_class.new('lintci/spin_cycle:latest', '/local/path')}
|
5
|
+
|
6
|
+
describe '#wrap' do
|
7
|
+
it 'wraps the command passed in with a call to docker' do
|
8
|
+
expect(container.wrap('ls')).to eq(
|
9
|
+
'docker run --privileged=false '\
|
10
|
+
"-v #{described_class::LOCAL_CONFIG_PATH}:/opt/lint_trap/config "\
|
11
|
+
'-v /local/path:/home/spin_cycle '\
|
12
|
+
'--workdir=/home/spin_cycle --user=spin_cycle lintci/spin_cycle:latest ls'
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#config_path' do
|
18
|
+
it 'returns the docker config_path' do
|
19
|
+
expect(container.config_path('')).to eq(described_class::CONFIG_PATH.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#container_path' do
|
24
|
+
it 'returns the absolute path of the file in the container' do
|
25
|
+
expect(container.container_path('/local/path/bad.file')).to eq('/home/spin_cycle/bad.file')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#local_path' do
|
30
|
+
it 'returns the absolute path of the file outside the container' do
|
31
|
+
expect(container.local_path('/home/spin_cycle/bad.file')).to eq('/local/path/bad.file')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Container::Fake do
|
4
|
+
subject(:container){described_class.new}
|
5
|
+
|
6
|
+
describe '#wrap' do
|
7
|
+
it 'returns the command passed in' do
|
8
|
+
expect(container.wrap('ls')).to eq('ls')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#config_path' do
|
13
|
+
it 'returns the gems config_path' do
|
14
|
+
expect(container.config_path('')).to eq(described_class::LOCAL_CONFIG_PATH.to_s)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#container_path' do
|
19
|
+
it 'returns the path passed in' do
|
20
|
+
expect(container.container_path('bad.file')).to eq('bad.file')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#local_path' do
|
25
|
+
it 'returns the path passed in' do
|
26
|
+
expect(container.local_path('bad.file')).to eq('bad.file')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
class xMen
|
@@ -0,0 +1 @@
|
|
1
|
+
class XMen
|
@@ -0,0 +1 @@
|
|
1
|
+
lint
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Linter::CheckStyle 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.java')}
|
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: 'com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck',
|
19
|
+
severity: 'error',
|
20
|
+
message: 'Missing a Javadoc comment.'
|
21
|
+
}, {
|
22
|
+
file: file,
|
23
|
+
line: '1',
|
24
|
+
column: '14',
|
25
|
+
length: nil,
|
26
|
+
rule: 'com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck',
|
27
|
+
severity: 'error',
|
28
|
+
message: "Name 'bad' must match pattern '^[A-Z][a-zA-Z0-9]*$'."
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when linting a good file' do
|
35
|
+
let(:file){fixture_path('Good.java')}
|
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::CoffeeLint 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.coffee')}
|
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: nil,
|
17
|
+
length: nil,
|
18
|
+
rule: 'camel_case_classes',
|
19
|
+
severity: 'error',
|
20
|
+
message: 'Class names should be camel cased'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when linting a good file' do
|
27
|
+
let(:file){fixture_path('good.coffee')}
|
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,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Linter::CPPCheck 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.cpp')}
|
10
|
+
|
11
|
+
it 'generates lint' do
|
12
|
+
expect{|b| linter.lint([file], &b)}.to yield_successive_args(
|
13
|
+
{
|
14
|
+
file: file,
|
15
|
+
line: '3',
|
16
|
+
column: nil,
|
17
|
+
length: nil,
|
18
|
+
rule: 'unassignedVariable',
|
19
|
+
severity: 'style',
|
20
|
+
message: "Variable 'p' is not assigned a value."
|
21
|
+
}, {
|
22
|
+
file: file,
|
23
|
+
line: '4',
|
24
|
+
column: nil,
|
25
|
+
length: nil,
|
26
|
+
rule: 'uninitvar',
|
27
|
+
severity: 'error',
|
28
|
+
message: 'Uninitialized variable: p'
|
29
|
+
}, {
|
30
|
+
file: file,
|
31
|
+
line: '1',
|
32
|
+
column: nil,
|
33
|
+
length: nil,
|
34
|
+
rule: 'unusedFunction',
|
35
|
+
severity: 'style',
|
36
|
+
message: "The function 'f' is never used."
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when linting a good file' do
|
43
|
+
let(:file){fixture_path('good.cpp')}
|
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,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Linter::CSSLint 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.css')}
|
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: '5',
|
17
|
+
length: nil,
|
18
|
+
rule: nil,
|
19
|
+
severity: 'Warning',
|
20
|
+
message: 'Using width with border can sometimes make elements larger than you expect.'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when linting a good file' do
|
27
|
+
let(:file){fixture_path('good.css')}
|
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,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LintTrap::Linter::GoLint 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.go')}
|
10
|
+
|
11
|
+
it 'generates lint' do
|
12
|
+
expect{|b| linter.lint([file], &b)}.to yield_successive_args(
|
13
|
+
{
|
14
|
+
file: file,
|
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'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when linting a good file' do
|
27
|
+
let(:file){fixture_path('good.go')}
|
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
|