code-scanning-rubocop 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09beea9b3ef6e114f880760f06d17dd25ba099ec4e77456f5cd2274b36551a4c'
4
- data.tar.gz: 6355d25dec4c91e28a5d88841b1bff44e4dec9495831ebcc1e7f6d06d0bd0b8f
3
+ metadata.gz: 739a88bd1b19ec2ee128962c43c90c7c3680e2e04ad8cfb98feb9773aa7419d8
4
+ data.tar.gz: f7f7aaa9fc8607ffe535494dcbfcd9ea1ac17620bba8073a9a67859064c45e28
5
5
  SHA512:
6
- metadata.gz: acb1fd0cf47857e36c53107481e4214e5ae45ec095977a4ba3a1c4a8c2778504b4d30a853d01e6fc78f3b9d12c6532470af731b2e39cb352764e486ea42fb246
7
- data.tar.gz: 5166198c7c0025fafc28150ae5479b90fbdbd270fdb1f2e596bedd9d66a9bbf23e1afa72b2209213e9cc578bf2c4163c942f71317604d3e86635b377117aca97
6
+ metadata.gz: 8c48865aedc4968ed50c8d6dfb1ae3e42b8b44fde53a82219e0b47bafcc0b51b84cb29642d7e29db5759caec0345a953a7940928bc85396aacbee393deb35ffe
7
+ data.tar.gz: 33a344112b71cba3ab3a77411173cff7bc96a88fb4d2df3db9536edbb86aa6ececf57052950cf4098daf6df5e18bf15c41af1d4e8635102ec300948768f6003c
data/Dockerfile CHANGED
@@ -3,7 +3,7 @@ FROM ruby:2.7.1
3
3
  # throw errors if Gemfile has been modified since Gemfile.lock
4
4
  RUN bundle config --global frozen 1
5
5
 
6
- RUN gem install code-scanning-rubocop
6
+ RUN gem install code-scanning-rubocop -v0.2.0
7
7
 
8
8
  ARG GITHUB_WORKSPACE
9
9
 
@@ -1,23 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-scanning-rubocop (0.1.0)
5
- activesupport
4
+ code-scanning-rubocop (0.2.0)
6
5
  rubocop (~> 0.82.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- activesupport (6.0.2.2)
12
- concurrent-ruby (~> 1.0, >= 1.0.2)
13
- i18n (>= 0.7, < 2)
14
- minitest (~> 5.1)
15
- tzinfo (~> 1.1)
16
- zeitwerk (~> 2.2)
17
10
  ast (2.4.0)
18
- concurrent-ruby (1.1.6)
19
- i18n (1.8.2)
20
- concurrent-ruby (~> 1.0)
21
11
  jaro_winkler (1.5.4)
22
12
  minitest (5.14.0)
23
13
  parallel (1.19.1)
@@ -35,11 +25,7 @@ GEM
35
25
  ruby-progressbar (~> 1.7)
36
26
  unicode-display_width (>= 1.4.0, < 2.0)
37
27
  ruby-progressbar (1.10.1)
38
- thread_safe (0.3.6)
39
- tzinfo (1.2.7)
40
- thread_safe (~> 0.1)
41
28
  unicode-display_width (1.7.0)
42
- zeitwerk (2.3.0)
43
29
 
44
30
  PLATFORMS
45
31
  ruby
@@ -30,6 +30,4 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_dependency 'rubocop', '~> 0.82.0'
33
- # TODO: remove this
34
- spec.add_dependency 'activesupport'
35
33
  end
@@ -4,5 +4,17 @@ set -x
4
4
 
5
5
  cd $GITHUB_WORKSPACE
6
6
 
7
- rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
8
- exit 0
7
+ # Install correct bundler version
8
+ gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
9
+
10
+ bundle install
11
+
12
+ bundle inject code-scanning-rubocop "$(gem list | grep code-scanning-rubocop | tr -cd '0-9.')"
13
+
14
+ bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
15
+
16
+ if [ ! -f rubocop.sarif ]; then
17
+ exit 1
18
+ else
19
+ exit 0
20
+ fi
@@ -1,12 +1,8 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require 'rubocop/formatter/base_formatter'
4
3
  require 'json'
5
- require 'active_support/all'
6
4
  require 'pathname'
7
5
 
8
- # TODO: fix me
9
- ROOT = __dir__
10
6
  module CodeScanning
11
7
 
12
8
  class SarifFormatter < RuboCop::Formatter::BaseFormatter
@@ -27,17 +23,9 @@ module CodeScanning
27
23
  },
28
24
  'results' => @results }
29
25
  ]
30
- # TODO: under runs
31
- # "tool" : {
32
- # "driver" : {
33
- # "name" : "CodeQL command-line toolchain",
34
- # "organization" : "GitHub",
35
- # "semanticVersion" : "2.0.0",
36
- # "rules" : [ {
37
26
  end
38
27
 
39
- Rule = Struct.new(:name, :index, :hash) do
40
- end
28
+ Rule = Struct.new(:name, :index)
41
29
 
42
30
  def set_rule(cop_name, severity)
43
31
  if r = @rules_map[cop_name]
@@ -59,14 +47,13 @@ module CodeScanning
59
47
  'properties' => {}
60
48
  }
61
49
  @rules << h
62
- @rules_map[cop_name] = Rule.new(cop_name, @rules.size - 1, h)
50
+ @rules_map[cop_name] = Rule.new(cop_name, @rules.size - 1)
63
51
  end
64
52
 
65
53
  def sarif_severity(cop_severity)
66
- return cop_severity if cop_severity.in? %w[warning error]
67
- return 'note' if cop_severity.in? %w[refactor convention]
68
- return 'error' if cop_severity.in? %w[fatal]
69
-
54
+ return cop_severity if %w[warning error].include?(cop_severity)
55
+ return 'note' if %w[refactor convention].include?(cop_severity)
56
+ return 'error' if cop_severity == 'fatal'
70
57
  'none'
71
58
  end
72
59
 
@@ -99,18 +86,9 @@ module CodeScanning
99
86
  }
100
87
  ],
101
88
  'partialFingerprints' => {
102
- # "primaryLocationLineHash" : "39fa2ee980eb94b0:1",
103
- # "primaryLocationStartColumnFingerprint" : "4"
89
+ # This will be computed by the upload action for now
104
90
  }
105
91
  }
106
-
107
- # # "%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
108
- # # path: file,
109
- # # line: o.line,
110
- # # column: o.real_column,
111
- # # severity: o.severity.code,
112
- # # message: message(o)
113
- # # )
114
92
  end
115
93
  end
116
94
 
@@ -1,5 +1,5 @@
1
1
  module CodeScanning
2
2
  module Rubocop
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-scanning-rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Neves
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-01 00:00:00.000000000 Z
11
+ date: 2020-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.82.0
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  description: This gem adds a SARIF formatter to rubocop, so we can export alerts to
42
28
  code-scanning inside GitHub.
43
29
  email:
@@ -61,7 +47,7 @@ files:
61
47
  - lib/code_scanning.rb
62
48
  - lib/code_scanning/rubocop/sarif_formatter.rb
63
49
  - lib/code_scanning/rubocop/version.rb
64
- - rubocop-scan/action.yml
50
+ - rubocop-action/action.yml
65
51
  homepage: https://github.com/arthurnn/code-scanning-rubocop
66
52
  licenses:
67
53
  - MIT