pronto-golang 0.0.7 → 0.0.8

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
- SHA1:
3
- metadata.gz: 44322a5abe5e297a8aca4dcbcaf6cadcc281aece
4
- data.tar.gz: 5e3a4285833911a46405d0ca87b52f4328917374
2
+ SHA256:
3
+ metadata.gz: 76519296caac98ba7adaba5317b737704d2e92c895a56629098b209f554f32ee
4
+ data.tar.gz: d9501233693ea8ef3f734e937ecd79b6f2f723a9524b0bc0aa0ef645e3d59fce
5
5
  SHA512:
6
- metadata.gz: cc3dc687d363a3a91ca82ab729aa548f8dcae82ab2999e7c239355674eaaf3661bf40ac67979e0dd099a59d25be3cd6d1e78a7106bb154ffda91cefa9c79b23c
7
- data.tar.gz: 2338419e929ff992ce3751d8fb546704d219e23b2e00dc8a5034de2200591d9bded52c60fe28b56d91345149ad64bbe11f4582580b9e7cad5856b82eb0eba1e2
6
+ metadata.gz: a22a2998ee44aa6fc3232c0d516b880ce61fce4cbc0eac7dc51f2a89fe402d46897c527ab3bf8ceec0d92b1cdc9db72d700cc7cce79df4dd0e7a6c77888b1473
7
+ data.tar.gz: 78261ce6a7bb74f0547dcaf1b77c56798b4b9517f5ce21eebcdcafe1ec76620050e81871525f83c7ee28111e05310a53b8eb74ea37c7a0f35d9b062dd68e165f
data/README.md CHANGED
@@ -8,9 +8,9 @@ Pronto runner for [Golang](https://golang.org) tools
8
8
 
9
9
  | Tool | Install |
10
10
  |----------|----------|
11
- | errcheck | go get -u github.com/kisielk/errcheck |
12
11
  | go vet | - |
13
12
  | golint | go get -u golang.org/x/lint/golint |
13
+ | gosec | See [Install instructions](https://github.com/securego/gosec#install) |
14
14
  | staticcheck | go get -u honnef.co/go/tools/cmd/staticcheck |
15
15
 
16
16
  ## Configuring tools
data/lib/pronto/golang.rb CHANGED
@@ -3,6 +3,7 @@ require 'pronto'
3
3
  require 'yaml'
4
4
  require 'shellwords'
5
5
 
6
+ require_relative './golang/errors'
6
7
  require_relative './golang/file_finder'
7
8
  require_relative './golang/tools'
8
9
 
@@ -56,18 +57,22 @@ module Pronto
56
57
  def process_line(patch, tool, output_line)
57
58
  return nil if output_line =~ /^#/
58
59
 
59
- file_path, line_number, level, message = tool.parse_line(output_line)
60
+ begin
61
+ file_path, line_number, level, message = tool.parse_line(output_line)
60
62
 
61
- patch.added_lines.each do |line|
62
- if line_number.to_s == line.new_lineno.to_s &&
63
- patch.new_file_full_path.to_s == File.expand_path(file_path)
63
+ patch.added_lines.each do |line|
64
+ if line_number.to_s == line.new_lineno.to_s &&
65
+ patch.new_file_full_path.to_s == File.expand_path(file_path)
64
66
 
65
- prefix_message = "#{tool.base_command}: #{message}"
67
+ prefix_message = "#{tool.base_command}: #{message}"
66
68
 
67
- return Message.new(
68
- file_path, line, level, prefix_message, line.commit_sha, self.class
69
- )
69
+ return Message.new(
70
+ file_path, line, level, prefix_message, line.commit_sha, self.class
71
+ )
72
+ end
70
73
  end
74
+ rescue ::Pronto::GolangSupport::UnprocessableLine
75
+ # Do nothing if the line is not processable
71
76
  end
72
77
 
73
78
  return nil
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module GolangSupport
3
+ class UnprocessableLine < RuntimeError; end
4
+ end
5
+ end
@@ -5,7 +5,7 @@ end
5
5
 
6
6
  require_relative './tools/base'
7
7
 
8
- require_relative './tools/errcheck'
9
8
  require_relative './tools/golint'
9
+ require_relative './tools/gosec'
10
10
  require_relative './tools/govet'
11
11
  require_relative './tools/staticcheck'
@@ -0,0 +1,32 @@
1
+ require 'pathname'
2
+
3
+ require_relative '../errors'
4
+
5
+ module Pronto
6
+ module GolangTools
7
+ class Gosec < Base
8
+ def self.base_command
9
+ 'gosec'
10
+ end
11
+
12
+ def parse_line(line)
13
+ # Accepts lines of the following format:
14
+ # [path_to_file:<line_number>] -
15
+ if line !~ /^\[(\S+):(\d+)\] - (.+)/
16
+ raise ::Pronto::GolangSupport::UnprocessableLine.new(line)
17
+ end
18
+
19
+ path = $1.strip
20
+ line_number = $2.strip
21
+ message = $3.strip
22
+
23
+ absolute_path = Pathname.new(path)
24
+ working_directory = Pathname.new(Dir.pwd)
25
+
26
+ file_path = absolute_path.relative_path_from(working_directory)
27
+
28
+ return file_path.to_s, line_number, :warning, message
29
+ end
30
+ end
31
+ end
32
+ end
@@ -10,7 +10,13 @@ module Pronto
10
10
  end
11
11
 
12
12
  def parse_line(line)
13
- file_path, line_number, message = line.split(':')
13
+ # Support handling messages like
14
+ # - spec/fixtures/test.git/main.go:18:2: unreachable code
15
+ # - spec/fixtures/test.git/main.go:18: something else
16
+ elements = line.split(':')
17
+ file_path = elements[0]
18
+ line_number = elements[1]
19
+ message = elements[-1]
14
20
 
15
21
  return file_path, line_number, :warning, message.to_s.strip
16
22
  end
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module GolangVersion
3
- VERSION = '0.0.7'.freeze
3
+ VERSION = '0.0.8'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-golang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto
@@ -63,11 +63,12 @@ files:
63
63
  - LICENSE
64
64
  - README.md
65
65
  - lib/pronto/golang.rb
66
+ - lib/pronto/golang/errors.rb
66
67
  - lib/pronto/golang/file_finder.rb
67
68
  - lib/pronto/golang/tools.rb
68
69
  - lib/pronto/golang/tools/base.rb
69
- - lib/pronto/golang/tools/errcheck.rb
70
70
  - lib/pronto/golang/tools/golint.rb
71
+ - lib/pronto/golang/tools/gosec.rb
71
72
  - lib/pronto/golang/tools/govet.rb
72
73
  - lib/pronto/golang/tools/staticcheck.rb
73
74
  - lib/pronto/golang/version.rb
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.2.2
95
+ rubygems_version: 2.7.6
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Pronto runner for golang tools
@@ -1,19 +0,0 @@
1
- module Pronto
2
- module GolangTools
3
- class Errcheck < Base
4
- def self.base_command
5
- 'errcheck'
6
- end
7
-
8
- def parse_line(line)
9
- file_path, line_number, _, _ = line.split(':')
10
-
11
- return file_path, line_number, :warning, message
12
- end
13
-
14
- def message
15
- 'Error response given but not checked'
16
- end
17
- end
18
- end
19
- end