lint_trap 0.0.11 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23aa32b336fd40453d65df5401d7247f0cd78e64
4
- data.tar.gz: e12d4b7aa5daa29c71115a4899fac0349f412fa7
3
+ metadata.gz: cd8b059140d1d4487ff867109b06886cee712990
4
+ data.tar.gz: 546a5bf4794e33d96cce6a0caf1eb06154f657e5
5
5
  SHA512:
6
- metadata.gz: 26a47d1550add4667f8df11d355b04350ba47bd31b815632bfbfb35a27743177ae5e2f21a8f49ec1d12653a9e02388c5a73de1602064fd8159057e0c9f413c80
7
- data.tar.gz: 72571debf32931940a598b6893b4e120c578a844cf302c62b194e80bdcd50b1455a2e4643b73d68de868c61d3368caa6b1ea71e8c124410d09632a962b50db43
6
+ metadata.gz: e5da1f4256d21805a0000e717de18bb7525544d1e9951ec6dff7c0532ba03815271fc0be2f85483fcc40d05545b26eb929cdaf143f0b1469394df5c050053e6a
7
+ data.tar.gz: 161a54aebfc888fa3cfe6524674be8f28dcddd23d9a35df5dcc0e66b903f92e57cbcc718aeb45a88393f6ed17f9c7beea57aca28cfe0a527c7456b7279d6aa98
data/Dockerfile CHANGED
@@ -121,7 +121,7 @@ ENV JAVA_HOME /usr/lib/jvm/java-7-oracle
121
121
 
122
122
  ### Go
123
123
  # SCMs for "go get", gcc for cgo
124
- RUN apt-get update
124
+ RUN apt-get update \
125
125
  && apt-get install -y \
126
126
  ca-certificates \
127
127
  curl \
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'English'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+ require_relative 'lib/lint_trap'
3
5
 
4
6
  $stdout.sync = true
5
7
 
6
8
  RSpec::Core::RakeTask.new(:spec)
7
9
 
8
- task :default => :spec
10
+ task default: :spec
9
11
 
10
12
  task :credentials do
11
13
  require 'fileutils'
@@ -19,13 +21,17 @@ task :credentials do
19
21
  end
20
22
 
21
23
  namespace :docker do
22
- module Docker
24
+ class Docker
23
25
  DOCKER_CACHE_PATH = File.expand_path('~/.docker')
24
26
  DOCKER_IMAGE_PATH = File.join(DOCKER_CACHE_PATH, 'image.tar')
25
- IMAGE_NAME = 'lintci/spin_cycle'
26
27
 
27
28
  BuildError = Class.new(StandardError)
28
29
 
30
+ attr_reader :linter
31
+
32
+ def initialize(linter)
33
+ @linter = linter
34
+ end
29
35
 
30
36
  def tag
31
37
  run("docker tag -f #{image_sha} #{image_latest}")
@@ -52,11 +58,11 @@ namespace :docker do
52
58
  end
53
59
 
54
60
  def build
55
- run("docker build -t #{image_sha} .")
61
+ run("docker build -t #{image_sha} ./docker/#{linter.name.downcase}")
56
62
  end
57
63
 
58
64
  def push
59
- run("docker login -e #{ENV['DOCKER_EMAIL']} -u #{ENV['DOCKER_USER']} -p #{ENV['DOCKER_PASSWORD']}")
65
+ run("docker login -e #{ENV['DOCKER_EMAIL']} -u #{ENV['DOCKER_USER']} -p #{ENV['DOCKER_PASSWORD']}", true)
60
66
  run("docker push #{image_sha}")
61
67
  run("docker push #{image_version}")
62
68
  run("docker push #{image_latest}")
@@ -64,25 +70,24 @@ namespace :docker do
64
70
 
65
71
  private
66
72
 
67
- def run(command)
68
- puts command
73
+ def run(command, suppress = false)
74
+ puts
75
+ puts command unless suppress
69
76
  system(command)
70
77
 
71
- raise BuildError, 'There was a problem executing the command.' unless $? == 0
78
+ raise BuildError, 'There was a problem executing the command.' unless $CHILD_STATUS == 0
72
79
  end
73
80
 
74
81
  def image_sha
75
- "#{IMAGE_NAME}:#{sha}"
82
+ "#{linter.image}:#{sha}"
76
83
  end
77
84
 
78
85
  def image_version
79
- require_relative 'lib/lint_trap/version'
80
-
81
- "#{IMAGE_NAME}:#{LintTrap::VERSION}"
86
+ linter.image_version
82
87
  end
83
88
 
84
89
  def image_latest
85
- "#{IMAGE_NAME}:latest"
90
+ "#{linter.image}:latest"
86
91
  end
87
92
 
88
93
  def sha
@@ -90,12 +95,17 @@ namespace :docker do
90
95
  end
91
96
  end
92
97
 
93
- include Docker
98
+ def for_each_linter(method)
99
+ LintTrap::Linter.all.each do |linter|
100
+ puts '', '#' * 80, linter.name, '#' * 80
101
+ Docker.new(linter).send(method)
102
+ end
103
+ end
94
104
 
95
- task(:tag){tag}
96
- task(:pull){pull}
97
- task(:load){load}
98
- task(:dump){dump}
99
- task(:build){build}
100
- task(:push){push}
105
+ task(:tag){for_each_linter(:tag)}
106
+ task(:pull){for_each_linter(:pull)}
107
+ task(:load){for_each_linter(:load)}
108
+ task(:dump){for_each_linter(:dump)}
109
+ task(:build){for_each_linter(:build)}
110
+ task(:push){for_each_linter(:push)}
101
111
  end
data/circle.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  machine:
2
2
  services:
3
3
  - docker
4
- environment:
5
- # DEBUG_LINTING: true
6
4
  checkout:
7
5
  pre:
8
6
  - git config --global user.email "circleci@lintci.com"
@@ -39,6 +39,8 @@
39
39
  <property name="basedir" value="${basedir}"/>
40
40
  -->
41
41
 
42
+ <property name="fileExtensions" value="java, properties, xml"/>
43
+
42
44
  <!-- Checks that a package-info.java file exists for each package. -->
43
45
  <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
44
46
  <!-- <module name="JavadocPackage"/> -->
@@ -152,7 +154,6 @@
152
154
  <module name="InnerAssignment"/>
153
155
  <module name="MagicNumber"/>
154
156
  <module name="MissingSwitchDefault"/>
155
- <module name="RedundantThrows"/>
156
157
  <module name="SimplifyBooleanExpression"/>
157
158
  <module name="SimplifyBooleanReturn"/>
158
159
 
@@ -0,0 +1,19 @@
1
+ FROM java:8u45-jre
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ # Bundled as config
16
+
17
+ ### Defaults ###
18
+ USER $user
19
+ WORKDIR $homedir
@@ -0,0 +1,21 @@
1
+ FROM node:0.12.3-slim
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV COFFEELINT_VERSION 1.9.7
16
+
17
+ RUN npm install -g coffeelint@$COFFEELINT_VERSION
18
+
19
+ ### Defaults ###
20
+ USER $user
21
+ WORKDIR $homedir
@@ -0,0 +1,24 @@
1
+ FROM debian:jessie
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV CPPCHECK_VERSION 1.67-1
16
+
17
+ RUN apt-get update \
18
+ && apt-get install -y \
19
+ cppcheck=$CPPCHECK_VERSION \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ ### Defaults ###
23
+ USER $user
24
+ WORKDIR $homedir
@@ -0,0 +1,21 @@
1
+ FROM node:0.12.3-slim
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV CSSLINT_VERSION 0.10.0
16
+
17
+ RUN npm install -g csslint@$CSSLINT_VERSION
18
+
19
+ ### Defaults ###
20
+ USER $user
21
+ WORKDIR $homedir
@@ -0,0 +1,19 @@
1
+ FROM golang:1.4.2
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ RUN go get github.com/golang/lint/golint
16
+
17
+ ### Defaults ###
18
+ USER $user
19
+ WORKDIR $homedir
@@ -0,0 +1,21 @@
1
+ FROM node:0.12.3-slim
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV JSHINT_VERSION 2.5.11
16
+
17
+ RUN npm install -g jshint@$JSHINT_VERSION
18
+
19
+ ### Defaults ###
20
+ USER $user
21
+ WORKDIR $homedir
@@ -0,0 +1,21 @@
1
+ FROM node:0.12.3-slim
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV JSONLINT_VERSION 0.0.4
16
+
17
+ RUN npm install -g durable-json-lint-cli@$JSONLINT_VERSION
18
+
19
+ ### Defaults ###
20
+ USER $user
21
+ WORKDIR $homedir
@@ -0,0 +1,24 @@
1
+ FROM debian:jessie
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV PYLINT_VERSION 1.3.1-3
16
+
17
+ RUN apt-get update \
18
+ && apt-get install -y \
19
+ pylint=$PYLINT_VERSION \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ ### Defaults ###
23
+ USER $user
24
+ WORKDIR $homedir
@@ -0,0 +1,21 @@
1
+ FROM ruby:2.2.2-slim
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV RUBOCOP_VERSION 0.31.0
16
+
17
+ RUN gem install rubocop:$RUBOCOP_VERSION
18
+
19
+ ### Defaults ###
20
+ USER $user
21
+ WORKDIR $homedir
@@ -0,0 +1,21 @@
1
+ FROM ruby:2.2.2-slim
2
+ MAINTAINER LintCI
3
+
4
+ ### Setup User ###
5
+ ENV user lint_trap
6
+ ENV group linters
7
+ ENV homedir /src/
8
+
9
+ RUN mkdir -p $homedir \
10
+ && groupadd -r $group -g 777 \
11
+ && useradd -u 666 -r -g $group -d $homedir -s /sbin/nologin -c "Docker image user" $user \
12
+ && chown -R $user:$group $homedir
13
+
14
+ ### Setup Linter ###
15
+ ENV SCSSLINT_VERSION 0.38.0
16
+
17
+ RUN gem install scss-lint:$SCSSLINT_VERSION
18
+
19
+ ### Defaults ###
20
+ USER $user
21
+ WORKDIR $homedir
@@ -14,11 +14,10 @@ module LintTrap
14
14
 
15
15
  def run(container)
16
16
  Bundler.with_clean_env do
17
- puts command(container) if ENV['DEBUG_LINTING']
18
17
  Open3.popen2e(command(container)) do |_, stdout, thread|
19
- yield stdout
18
+ yield stdout if block_given?
20
19
 
21
- thread.join
20
+ thread.value.success?
22
21
  end
23
22
  end
24
23
  end
@@ -1,8 +1,11 @@
1
1
  require 'pathname'
2
+ require_relative '../execution_error'
2
3
 
3
4
  module LintTrap
4
5
  module Container
5
6
  class Base
7
+ ImagePullError = Class.new(ExecutionError)
8
+
6
9
  LOCAL_CONFIG_PATH = Pathname.new(File.expand_path('../../../../config', __FILE__))
7
10
 
8
11
  def initialize(image, repo_path)
@@ -10,16 +13,20 @@ module LintTrap
10
13
  @repo_path = Pathname.new(repo_path)
11
14
  end
12
15
 
16
+ def pull
17
+ raise NotImplementedError, 'Must implement pull.'
18
+ end
19
+
13
20
  def wrap(_command)
14
- raise NotImplementedError
21
+ raise NotImplementedError, 'Must implement wrap.'
15
22
  end
16
23
 
17
24
  def config_path(_path)
18
- raise NotImplementedError
25
+ raise NotImplementedError, 'Must implement config_path.'
19
26
  end
20
27
 
21
28
  def file_path(_path)
22
- raise NotImplementedError
29
+ raise NotImplementedError, 'Must implement file_path.'
23
30
  end
24
31
 
25
32
  protected
@@ -1,12 +1,24 @@
1
1
  require_relative 'base'
2
2
  require 'pathname'
3
+ require 'open3'
3
4
 
4
5
  module LintTrap
5
6
  module Container
6
7
  # Acts like a container, without actually requiring a container.
7
8
  class Docker < Base
8
- CONFIG_PATH = Pathname.new('/opt/lint_trap/config')
9
- CODE_PATH = Pathname.new('/home/spin_cycle')
9
+ CONFIG_PATH = Pathname.new('/config')
10
+ CODE_PATH = Pathname.new('/src')
11
+
12
+ def pull
13
+ command = "docker pull #{image}"
14
+ Open3.popen2e(command) do |_, stdout, thread|
15
+ if thread.value.success?
16
+ true
17
+ else
18
+ raise ImagePullError.new(command, stdout.read)
19
+ end
20
+ end
21
+ end
10
22
 
11
23
  def wrap(command)
12
24
  "docker run #{flags} #{image} #{command}"
@@ -34,11 +46,12 @@ module LintTrap
34
46
  [
35
47
  # '-m', '50m', # memory
36
48
  # '-c', '1', # number of cpus
49
+ '--net="none"',
37
50
  '--privileged=false',
38
51
  '-v', "#{LOCAL_CONFIG_PATH}:#{CONFIG_PATH}",
39
52
  '-v', "#{repo_path}:#{CODE_PATH}",
40
53
  "--workdir=#{CODE_PATH}",
41
- '--user=spin_cycle'
54
+ '--user=lint_trap'
42
55
  ].join(' ')
43
56
  end
44
57
  end
@@ -8,6 +8,9 @@ module LintTrap
8
8
  super('no/image', 'local')
9
9
  end
10
10
 
11
+ def pull
12
+ end
13
+
11
14
  def wrap(command)
12
15
  command
13
16
  end
@@ -0,0 +1,12 @@
1
+ module LintTrap
2
+ # Error thrown from code that executes an external command.
3
+ class ExecutionError < StandardError
4
+ attr_reader :command, :output
5
+
6
+ def initialize(command, output)
7
+ super("An error occurred while running `#{command}`. The output was:\n#{output}")
8
+ @command = command
9
+ @output = output
10
+ end
11
+ end
12
+ end
@@ -1,8 +1,11 @@
1
1
  require_relative '../parser/standard'
2
2
  require_relative '../command'
3
+ require_relative '../execution_error'
3
4
 
4
5
  module LintTrap
5
6
  module Linter
7
+ LintError = Class.new(ExecutionError)
8
+
6
9
  # The base class for all linters. Provides a template for linter execution.
7
10
  class Base
8
11
  CONFIG_PATH = File.expand_path('../../../../config', __FILE__)
@@ -10,19 +13,35 @@ module LintTrap
10
13
  def lint(files, container, options)
11
14
  return unless known?
12
15
 
13
- @container, @options = container, options
14
-
15
- command(files).run(container) do |stdout|
16
- parser(stdout).parse do |violation|
16
+ violations_found, remaining_output = false, ''
17
+ success = command(files, container, options).run(container) do |stdout|
18
+ remaining_output = parser(stdout, container).parse do |violation|
19
+ violations_found = true
17
20
  yield violation
18
21
  end
19
22
  end
23
+
24
+ if !violations_found && !success
25
+ raise LintError.new(command(files, container, options).to_s(container), remaining_output)
26
+ end
20
27
  end
21
28
 
22
29
  def name
23
30
  self.class.name.split('::').last
24
31
  end
25
32
 
33
+ def version
34
+ raise NotImplementedError, 'Must implement version.'
35
+ end
36
+
37
+ def image
38
+ "lintci/#{name.downcase}"
39
+ end
40
+
41
+ def image_version
42
+ "#{image}:#{version}"
43
+ end
44
+
26
45
  def languages(*classes)
27
46
  classes.map(&:new)
28
47
  end
@@ -41,29 +60,21 @@ module LintTrap
41
60
  "<#{name}>"
42
61
  end
43
62
 
44
- protected
45
-
46
- attr_reader :container, :options
47
-
48
63
  private
49
64
 
50
- def command(files)
51
- Command.new(command_name, flags, files)
65
+ def command(files, container, options)
66
+ Command.new(command_name(container), flags(container, options), files)
52
67
  end
53
68
 
54
- def parser(stdout)
69
+ def parser(stdout, container)
55
70
  LintTrap::Parser::Standard.new(stdout, container)
56
71
  end
57
72
 
58
- def config_path(path)
59
- container.config_path(path)
60
- end
61
-
62
- def flags(options)
63
- raise NotImplementedError, 'Method flags must be implemented.'
73
+ def flags(_container, _options)
74
+ raise NotImplementedError, 'Must implement flags.'
64
75
  end
65
76
 
66
- def command_name
77
+ def command_name(_container)
67
78
  name.downcase
68
79
  end
69
80
  end
@@ -4,23 +4,30 @@ module LintTrap
4
4
  module Linter
5
5
  # Encapsulates logic specific to checkstyle command line tool.
6
6
  class CheckStyle < Base
7
- JAR = 'checkstyle/checkstyle_logger-all.jar'
8
7
  CHECKS_XML = 'checkstyle/sun_checks.xml'
9
8
 
10
9
  def languages
11
10
  super(Language::Java)
12
11
  end
13
12
 
13
+ def version
14
+ '6.6'
15
+ end
16
+
17
+ def jar
18
+ "checkstyle/checkstyle_logger-#{version}-all.jar"
19
+ end
20
+
14
21
  private
15
22
 
16
- def command_name
23
+ def command_name(_container)
17
24
  'java'
18
25
  end
19
26
 
20
- def flags
27
+ def flags(container, options)
21
28
  [
22
- '-jar', config_path(JAR),
23
- '-c', options[:config] || config_path(CHECKS_XML)
29
+ '-jar', container.config_path(jar),
30
+ '-c', options[:config] || container.config_path(CHECKS_XML)
24
31
  ]
25
32
  end
26
33
  end
@@ -10,11 +10,15 @@ module LintTrap
10
10
  super(Language::CoffeeScript)
11
11
  end
12
12
 
13
+ def version
14
+ '1.9.7'
15
+ end
16
+
13
17
  private
14
18
 
15
- def flags
19
+ def flags(container, options)
16
20
  [
17
- "--reporter=#{config_path(REPORTER)}",
21
+ "--reporter=#{container.config_path(REPORTER)}",
18
22
  '--nocolor'
19
23
  ].tap do |flags|
20
24
  flags.concat(["--file=#{options[:config]}"]) if options[:config]
@@ -8,9 +8,13 @@ module LintTrap
8
8
  super(Language::CPP)
9
9
  end
10
10
 
11
+ def version
12
+ '1.67-1'
13
+ end
14
+
11
15
  private
12
16
 
13
- def flags
17
+ def flags(_container, _options)
14
18
  [
15
19
  '--enable=all',
16
20
  '--error-exitcode=1',