code-scanning-rubocop 0.5.0 → 0.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20b12a5a36ae8bf6f57d41d1386088d0b2701437dfca90d7807c79569b70b54f
4
- data.tar.gz: 34cb6723cee9ab3de438578b010f4d112d197c41711ba18b81afd289f77dd934
3
+ metadata.gz: aede2d4f861c011d78db9d9f6df567bdd94322ed40951f3d15613b844e3e48b5
4
+ data.tar.gz: d2fdb4fc5b34b560c5a9af454def6730d75c4ed80cbfd6865027175df10b393c
5
5
  SHA512:
6
- metadata.gz: b62c756e603d4445f61326901c47e470553e30f67d823f71dd2afe742c33cd41fdd46d4ad7b4b81bc30d55e5c7ade2359a1fd31b18e7240cf45c4e0fc424a3d9
7
- data.tar.gz: 37ee5b0acd4d306cd23fca13d011c986471ea7b204f6f2d3a606340d413ede966b9f69f9855db68831dc12d59c87fdd946ae67003ad1c7b4fb0e2be915397b80
6
+ metadata.gz: f44b470a1e45e04a535fb6becc9ee6348da281405ea14cd96f726894327bec3523ecd627ece9b2426ae409ca13f14d9eaca5110d4bd5b8ba9515d1ad60edd7bd
7
+ data.tar.gz: 5f790f1cdcfb47d202e7b4afb613450ebe108fa3cc3b301140ee14cf98b63f7b15b2ad694a7be6ec29968569905e4029cdbfea5fe3b7c353b3d7651785998286
data/Gemfile.lock CHANGED
@@ -1,34 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-scanning-rubocop (0.3.0)
5
- rubocop (> 0.82.0)
4
+ code-scanning-rubocop (0.5.0)
5
+ rubocop (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.1)
10
+ ast (2.4.2)
11
11
  minitest (5.14.0)
12
- parallel (1.19.2)
13
- parser (2.7.1.5)
12
+ parallel (1.21.0)
13
+ parser (3.1.0.0)
14
14
  ast (~> 2.4.1)
15
- rainbow (3.0.0)
15
+ rainbow (3.1.1)
16
16
  rake (12.3.3)
17
- regexp_parser (1.8.0)
18
- rexml (3.2.4)
19
- rubocop (0.92.0)
17
+ regexp_parser (2.2.0)
18
+ rexml (3.2.5)
19
+ rubocop (1.24.1)
20
20
  parallel (~> 1.10)
21
- parser (>= 2.7.1.5)
21
+ parser (>= 3.0.0.0)
22
22
  rainbow (>= 2.2.2, < 4.0)
23
- regexp_parser (>= 1.7)
23
+ regexp_parser (>= 1.8, < 3.0)
24
24
  rexml
25
- rubocop-ast (>= 0.5.0)
25
+ rubocop-ast (>= 1.15.1, < 2.0)
26
26
  ruby-progressbar (~> 1.7)
27
- unicode-display_width (>= 1.4.0, < 2.0)
28
- rubocop-ast (0.5.0)
29
- parser (>= 2.7.1.5)
30
- ruby-progressbar (1.10.1)
31
- unicode-display_width (1.7.0)
27
+ unicode-display_width (>= 1.4.0, < 3.0)
28
+ rubocop-ast (1.15.1)
29
+ parser (>= 3.0.1.1)
30
+ ruby-progressbar (1.11.0)
31
+ unicode-display_width (2.1.0)
32
32
 
33
33
  PLATFORMS
34
34
  ruby
@@ -39,4 +39,4 @@ DEPENDENCIES
39
39
  rake (~> 12.0)
40
40
 
41
41
  BUNDLED WITH
42
- 2.1.4
42
+ 2.3.4
@@ -8,19 +8,19 @@ module CodeScanning
8
8
  @cop_name = cop_name
9
9
  @severity = severity.to_s
10
10
  @cop = RuboCop::Cop::Cop.registry.find_by_cop_name(cop_name)
11
- @help = StringIO.new
12
11
  end
13
12
 
14
13
  def id
15
14
  @cop_name
16
15
  end
17
16
 
18
- def append_help(line)
19
- @help.print(line)
20
- end
21
-
22
- def help_empty?
23
- @help.size.zero?
17
+ def help(format)
18
+ case format
19
+ when :text
20
+ "More info: #{help_uri}"
21
+ when :markdown
22
+ "[More info](#{help_uri})"
23
+ end
24
24
  end
25
25
 
26
26
  def ==(other)
@@ -41,12 +41,36 @@ module CodeScanning
41
41
  "none"
42
42
  end
43
43
 
44
- # The URL for the docs are in this format:
45
- # https://docs.rubocop.org/en/stable/cops_layout/#layoutblockendnewline
46
- def query_uri
47
- kind = badge.department.to_s.downcase
48
- full_name = "#{kind}#{badge.cop_name.downcase}"
49
- "https://docs.rubocop.org/en/stable/cops_#{kind}/##{full_name}"
44
+ def help_uri
45
+ return @cop.documentation_url if @cop.documentation_url
46
+ return nil unless department_uri
47
+
48
+ anchor = "#{badge.department}#{badge.cop_name}".downcase.tr("/", "")
49
+ "#{department_uri}##{anchor}"
50
+ end
51
+
52
+ def department_uri
53
+ case badge.department
54
+ when :Performance
55
+ "https://docs.rubocop.org/rubocop-performance/index.html"
56
+ when :Packaging
57
+ "https://docs.rubocop.org/rubocop-packaging/cops_packaging.html"
58
+ when :Rails
59
+ "https://docs.rubocop.org/rubocop-rails/cops_rails.html"
60
+ when :Minitest
61
+ "https://docs.rubocop.org/rubocop-minitest/cops_minitest.html"
62
+ when :RSpec
63
+ "https://docs.rubocop.org/rubocop-rspec/cops_rspec.html"
64
+ when :"RSpec/Rails"
65
+ "https://docs.rubocop.org/rubocop-rspec/cops_rspec_rails.html"
66
+ when :"RSpec/Capybara"
67
+ "https://docs.rubocop.org/rubocop-rspec/cops_rspec_capybara.html"
68
+ when :"RSpec/FactoryBot"
69
+ "https://docs.rubocop.org/rubocop-rspec/cops_rspec_factorybot.html"
70
+ else
71
+ STDERR.puts "WARNING: Unknown docs URI for department #{badge.department}"
72
+ nil
73
+ end
50
74
  end
51
75
 
52
76
  def to_json(opts = {})
@@ -66,7 +90,7 @@ module CodeScanning
66
90
 
67
91
  h = {
68
92
  "id" => @cop_name,
69
- "name" => @cop_name,
93
+ "name" => @cop_name.tr("/", "").gsub("RSpec", "Rspec"),
70
94
  "defaultConfiguration" => {
71
95
  "level" => sarif_severity
72
96
  },
@@ -80,19 +104,22 @@ module CodeScanning
80
104
  properties["description"] = desc
81
105
  end
82
106
 
83
- unless help_empty?
84
- help = @help.string
85
- h["help"] = {
86
- "text" => help,
87
- "markdown" => help
88
- }
89
- properties["queryURI"] = query_uri if badge.qualified?
90
- end
91
-
92
107
  if badge.qualified?
93
108
  kind = badge.department.to_s
94
109
  properties["tags"] = [kind.downcase]
95
110
  end
111
+
112
+ if help_uri
113
+ h.merge!(
114
+ "queryURI" => help_uri,
115
+ "helpUri" => help_uri,
116
+ "help" => {
117
+ "text" => help(:text),
118
+ "markdown" => help(:markdown)
119
+ }
120
+ )
121
+ end
122
+
96
123
  h
97
124
  end
98
125
  end
@@ -17,7 +17,12 @@ module CodeScanning
17
17
  @sarif["runs"] = [
18
18
  {
19
19
  "tool" => {
20
- "driver" => { "name" => "RuboCop", "rules" => @rules }
20
+ "driver" => {
21
+ "name" => "RuboCop",
22
+ "version" => RuboCop::Version.version,
23
+ "informationUri" => "https://rubocop.org",
24
+ "rules" => @rules
25
+ }
21
26
  },
22
27
  "results" => @results
23
28
  }
@@ -52,7 +57,6 @@ module CodeScanning
52
57
  "artifactLocation" => {
53
58
  "uri" => relative_path,
54
59
  "uriBaseId" => "%SRCROOT%",
55
- "index" => 0
56
60
  },
57
61
  "region" => {
58
62
  "startLine" => o.line,
@@ -61,10 +65,7 @@ module CodeScanning
61
65
  }
62
66
  }
63
67
  }
64
- ],
65
- "partialFingerprints" => {
66
- # This will be computed by the upload action for now
67
- }
68
+ ]
68
69
  }
69
70
  end
70
71
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CodeScanning
4
4
  module Rubocop
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  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.5.0
4
+ version: 0.6.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-12-28 00:00:00.000000000 Z
11
+ date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.1.2
79
+ rubygems_version: 3.3.3
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Extra formater to make rubocop compatible with GitHub's code-scanning feature.