lib/sonar/plugin.rb in danger-sonar-1.0 vs lib/sonar/plugin.rb in danger-sonar-1.0.1
- old
+ new
@@ -46,10 +46,13 @@
attr_accessor :minor_count
# Total Sonar info issues found in PR changes
attr_accessor :info_count
+ # To log additional information for debuging.
+ attr_accessor :verbose
+
# Lints Swift files.
# Generates a `markdown` list of issues(Blocker, Major, Minor, Info) for the prose in a corpus of .markdown and .md files.
#
# @param [String] files
# A globbed string which should return the files that you want to lint, defaults to nil.
@@ -60,13 +63,15 @@
# Fails if invalid JSON report file isn't installed
raise "Sonar report file name is empty" unless !json_report_file.empty?
# Extract excluded paths
excluded_paths = excluded_files_from_config(config_file)
+ log "Sonar - Excluded paths #{excluded_paths}"
# Extract swift files (ignoring excluded ones)
files = find_files(files, excluded_paths)
+ log "Sonar - Included files #{files}"
#file = File.read(json_report_file)
#sonar_report_data = JSON.parse(file)
@@ -74,10 +79,12 @@
options = {
report: File.expand_path(json_report_file),
config: config_file
}
+ log "Sonar - options #{options}"
+
# Lint each file and collect the results
issues = analyse_sonar_report(files, options)
puts "Issues: #{issues}"
# Filter warnings and errors
@@ -254,8 +261,12 @@
dir = "#{Dir.pwd}/"
results.each do |r|
filename = r['file'].gsub(dir, "")
send(method, r['reason'], file: filename, line: r['line'])
end
+ end
+
+ def log(text)
+ puts(text) if @verbose
end
end
end