Class: Pronto::GolangTools::Gosec
- Defined in:
- lib/pronto/golang/tools/gosec.rb
Constant Summary collapse
- GOSEC_LINE_PATTERN =
Accepts lines of the following format:
[path_to_file:<line_number>] -
Regexp.new('^\[(\S+):(\d+)\] - (.+)')
- ANSI_COLOR_CODING_PATTERN =
Regexp.new('\e\[\d+(;\d+)?m')
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#available?, #base_command, #blacklisted_files_regexp, #directory, #enabled?, #execution_mode, #initialize, #installed?, #parameters
Constructor Details
This class inherits a constructor from Pronto::GolangTools::Base
Class Method Details
.base_command ⇒ Object
15 16 17 |
# File 'lib/pronto/golang/tools/gosec.rb', line 15 def self.base_command 'gosec' end |
Instance Method Details
#command(file_path) ⇒ Object
19 20 21 |
# File 'lib/pronto/golang/tools/gosec.rb', line 19 def command(file_path) "#{base_command} #{parameters} #{File.dirname(file_path)}" end |
#parse_line(line) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pronto/golang/tools/gosec.rb', line 23 def parse_line(line) line = line.gsub(ANSI_COLOR_CODING_PATTERN, '') if !GOSEC_LINE_PATTERN.match(line) raise ::Pronto::GolangSupport::UnprocessableLine.new(line) end path = $1.strip line_number = $2.strip = $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, end |