Class: Pronto::GolangTools::Gosec

Inherits:
Base
  • Object
show all
Defined in:
lib/pronto/golang/tools/gosec.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#available?, #base_command, #enabled?, #initialize, #installed?, #parameters

Constructor Details

This class inherits a constructor from Pronto::GolangTools::Base

Class Method Details

.base_commandObject



8
9
10
# File 'lib/pronto/golang/tools/gosec.rb', line 8

def self.base_command
  'gosec'
end

Instance Method Details

#command(file_path) ⇒ Object



12
13
14
# File 'lib/pronto/golang/tools/gosec.rb', line 12

def command(file_path)
  "#{base_command} #{parameters} #{File.dirname(file_path)}"
end

#parse_line(line) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pronto/golang/tools/gosec.rb', line 16

def parse_line(line)
  # Accepts lines of the following format:
  #   [path_to_file:<line_number>] -
  if line !~ /^\[(\S+):(\d+)\] - (.+)/
    raise ::Pronto::GolangSupport::UnprocessableLine.new(line)
  end

  path        = $1.strip
  line_number = $2.strip
  message     = $3.strip

  absolute_path = Pathname.new(path)
  working_directory = Pathname.new(Dir.pwd)

  file_path = absolute_path.relative_path_from(working_directory)

  return file_path.to_s, line_number, :warning, message
end