bake-toolkit 2.35.3 → 2.36.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
  SHA1:
3
- metadata.gz: 3b8d306c7cd1654955f1d8ad8d37f28cf38b8e40
4
- data.tar.gz: 1dbeadb6be8b3454a9ddb5be6adfd376bdc404a0
3
+ metadata.gz: 405e09a71d1a19b3fc8afd55052713096efc20be
4
+ data.tar.gz: 9e6f9eb763a0640ad0e7df22f573b6617a027bfd
5
5
  SHA512:
6
- metadata.gz: a27861ef5642b2db75e782dfd7e24649b697d1230ab9ab1b7b8abb4e81bd3053a3ffc8b6bbed70a3c02302861358249cdfdca5541cfa5bd87ad95fbc806d98f7
7
- data.tar.gz: b456e782115014abcdc8873e5f97d2c8baa878c1e9d4e4b6a98987d1d9de2d17af72d3cd3d8f5870e18d325ce053852f9a0c41ad4937ecb4c44afcd859564036
6
+ metadata.gz: d785d2498ec565930d8661494d20b1d182f93bab7bb140e9b86b8d22ceb04579f461bcb02bdffa23da40f1171262d7588f36019404313819056ec33daa89b075
7
+ data.tar.gz: 5533af6a837fe9998da11d02fd026d3161a452ea67dc4fc9fb63819efb8482db346bb6b544944392849329813486a73fe721471d408baea2bd759a1657e9b487
@@ -5,10 +5,12 @@ require 'fileutils'
5
5
  $:.unshift(File.dirname(__FILE__)+"/../lib")
6
6
 
7
7
  require "bakeqac/options/options"
8
+ require "bakeqac/filter"
8
9
  require 'bake/toolchain/colorizing_formatter'
9
10
  require 'bake/options/options'
10
11
  require 'common/process'
11
12
  require 'common/utils'
13
+ require 'common/ext/file'
12
14
 
13
15
  STDOUT.sync = true
14
16
  STDERR.sync = true
@@ -78,6 +80,7 @@ end
78
80
  @options = BakeqacOptions.new(ARGV)
79
81
  bakeOptions = Options.new([])
80
82
  @options.parse_options(bakeOptions)
83
+ pfilter = ProjectFilter.new(@options)
81
84
  success = false
82
85
 
83
86
  ###### PREREQUISITE 2: BAKE OPTIONS ######
@@ -199,9 +202,7 @@ end
199
202
  if @options.qacfilter
200
203
  if success
201
204
  puts filterOutput
202
- File.open("#{@options.qacdata}/filter.txt", "w+") do |f|
203
- f.puts(filter.uniq)
204
- end
205
+ ProjectFilter.writeFilter(filter)
205
206
  else
206
207
  puts consoleOutput # error
207
208
  end
@@ -218,16 +219,6 @@ end
218
219
 
219
220
  puts "bakeqac: printing results..."
220
221
 
221
- filter = []
222
- useFilter = File.exist?("#{@options.qacdata}/filter.txt") && @options.qacfilter
223
-
224
- if useFilter
225
- File.open("#{@options.qacdata}/filter.txt", "r") do |f|
226
- f.each_line { |line| filter << line.strip }
227
- end
228
- filter.delete_if { |f| (f.end_with? "/gtest") or (f.end_with? "/gmock") }
229
- end
230
-
231
222
  cmd = qaExe + ["view", "-P", @options.qacdata, "-m", "STDOUT"]
232
223
  if not @options.qacnoformat
233
224
  cmd += ["-f", "%?u==0%(MSG: %:trc: %)%F(%l,%c): (%r:%N)%t%?v%(\n%v%)"]
@@ -235,7 +226,7 @@ end
235
226
 
236
227
  success, consoleOutput, checkError = executeQacli(cmd)
237
228
 
238
- if useFilter
229
+ if ProjectFilter.is_valid?
239
230
 
240
231
  if !checkError # success # HACK: seems that QAC returns with error if there too much issues
241
232
  # 1. filter
@@ -247,12 +238,7 @@ end
247
238
  scan_res = line.scan(/\/\/ ======= Results for ([a-zA-Z]{0,1})(:{0,1})(.*)/)
248
239
  if scan_res.length > 0
249
240
  converted_line = (scan_res[0][0].downcase + scan_res[0][1] + scan_res[0][2].gsub(/\\/,"/"))
250
- filter.each do |fil|
251
- if converted_line.include?(fil+"/") and not converted_line.include?(fil+"/test/") and not converted_line.include?(fil+"/mock/") and not converted_line.include?(fil+"/.qacdata/")
252
- foundFile = true
253
- break
254
- end
255
- end
241
+ foundFile = ProjectFilter.localFile(converted_line)
256
242
  end
257
243
  if foundFile && !line.include?("QAC++ Deep Flow Static Analyser")
258
244
  filteredLines << line
@@ -383,6 +369,55 @@ end
383
369
 
384
370
  end
385
371
 
372
+ ###### STEP 5: REPORT MDR (OPTIONAL) ######
373
+
374
+ if success and !@options.qacstep.nil? and @options.qacstep.include?("mdr")
375
+ FileUtils::mkdir_p @options.qacdata
376
+
377
+ puts "bakeqac: generating MDR report..."
378
+
379
+ cmd = qaExe + ["report", "-P", @options.qacdata, "-t", "MDR"]
380
+
381
+ success, consoleOutput = ProcessHelper.run(cmd, false)
382
+ puts consoleOutput
383
+
384
+ if success
385
+ require "json"
386
+ jsons = Dir.glob(@options.qacdata + "/prqa/reports/data/*.json")
387
+
388
+ maxComplexity = 0
389
+ numGreater10 = 0
390
+ jsons.each do |file|
391
+ raw = File.read(file)
392
+ data = JSON.parse(raw)
393
+
394
+ filename = File.normalize(data["file"])
395
+
396
+ if ProjectFilter.localFile(filename)
397
+ Bake.formatter.printAdditionalInfo(filename)
398
+ entities = data["entities"]
399
+ if Array === entities
400
+ entities.each do |e|
401
+ if e.has_key?("type") && e["type"] == "function"
402
+ if e.has_key?("metrics") && e["metrics"].has_key?("STCYC")
403
+ complexity = e["metrics"]["STCYC"].to_i
404
+ str = " #{e["name"]}:#{e["line"]}: cyclomatic complexity = #{complexity}"
405
+ complexity > 10 ? Bake.formatter.printWarning(str) : puts(str)
406
+ maxComplexity = complexity if complexity > maxComplexity
407
+ numGreater10 +=1 if complexity > 10
408
+ end
409
+ end
410
+ end
411
+ end
412
+ end
413
+ end
414
+ Bake.formatter.printInfo("\n**** Maximum cyclomatic complexity: #{maxComplexity} ****")
415
+ resultStr = "**** Number of functions with cyclomatic complexity > 10: #{numGreater10} ****"
416
+ numGreater10 > 0 ? Bake.formatter.printWarning(resultStr) : Bake.formatter.printSuccess(resultStr)
417
+ else
418
+ Bake.formatter.printError("Failed to generate MDR report.")
419
+ end
420
+ end
386
421
 
387
422
  #### TODO: unittest for report
388
423
 
@@ -0,0 +1,47 @@
1
+ module Bake
2
+
3
+ class ProjectFilter
4
+
5
+ def initialize(options)
6
+ @@filterList = nil
7
+ @@valid = nil
8
+ @@options = options
9
+ @@filter_filename = "#{@@options.qacdata}/filter.txt"
10
+ end
11
+
12
+ def self.projects
13
+ calcFilter_internal() if @@filterList.nil?
14
+ return @@filterList
15
+ end
16
+
17
+ def self.is_valid?
18
+ calcFilter_internal() if @@valid.nil?
19
+ return @@valid
20
+ end
21
+
22
+ def self.localFile(str)
23
+ return true if not is_valid?
24
+ projects.any? { |fil| str.include?(fil+"/") and not str.include?(fil+"/test/") and not str.include?(fil+"/mock/") and not str.include?(fil+"/.qacdata/") }
25
+ end
26
+
27
+ def self.writeFilter(filter)
28
+ File.open(@@filter_filename, "w+") do |f|
29
+ filter.uniq!
30
+ filter.delete_if { |f| (f.end_with? "/gtest") or (f.end_with? "/gmock") }
31
+ f.puts(filter)
32
+ end
33
+ end
34
+
35
+ def self.calcFilter_internal
36
+ @@filterList = []
37
+ @@valid = File.exist?(@@filter_filename) && @@options.qacfilter
38
+ if @@valid
39
+ File.open(@@filter_filename, "r") do |f|
40
+ f.each_line { |line| @@filterList << line.strip }
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ end
@@ -63,7 +63,7 @@ module Bake
63
63
  puts " --acf <file> Set a specific analysis config file, otherwise $(QAC_HOME)/config/acf/default.acf will be used."
64
64
  puts " --qaccctpatch If specified, some adaptions to cct are made. Might improve the result - no guarantee."
65
65
  puts " --qacdata <dir> QAC writes data into this folder. Default is <working directory>/.qacdata."
66
- puts " --qacstep admin|analyze|view|report Steps can be ORed. Per default admin|analyze|view will be executed."
66
+ puts " --qacstep admin|analyze|view|report|mdr Steps can be ORed. Per default admin|analyze|view will be executed."
67
67
  puts " --qacnofilter Output will be printed immediately and unfiltered. Per default filters are used to reduce noise."
68
68
  puts " --qacrawformat Raw QAC output (with incomplete MISRA rules!)."
69
69
  puts " --qacretry <seconds> If build or result step fail due to refused license, the step will be retried until timeout."
@@ -129,7 +129,7 @@ module Bake
129
129
 
130
130
  if !@qacstep.nil?
131
131
  @qacstep.split("|").each do |s|
132
- if not ["admin", "analyze", "view", "report"].include?s
132
+ if not ["admin", "analyze", "view", "report", "mdr"].include?s
133
133
  Bake.formatter.printError("Error: incorrect qacstep name.")
134
134
  ExitHelper.exit(1)
135
135
  end
@@ -8,6 +8,14 @@ class File
8
8
  filename[0] == SLASH or filename[1] == ':'
9
9
  end
10
10
 
11
+ def self.normalize(filename)
12
+ if filename.length > 1
13
+ toIsWindowsAbs = filename[1] == ':'
14
+ return filename[0].downcase + filename[1..-1] if toIsWindowsAbs
15
+ end
16
+ return filename
17
+ end
18
+
11
19
  # seems both are rel or both are abs in all cases
12
20
  def self.rel_from_to_project(from,to,endWithSlash = true)
13
21
 
@@ -1,7 +1,7 @@
1
1
  module Bake
2
2
  class Version
3
3
  def self.number
4
- "2.35.3"
4
+ "2.36.0"
5
5
  end
6
6
 
7
7
  def self.printBakeVersion(ry = "")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-toolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.35.3
4
+ version: 2.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Schaal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rtext
@@ -190,6 +190,7 @@ files:
190
190
  - lib/bake/toolchain/ti.rb
191
191
  - lib/bake/util.rb
192
192
  - lib/bakeclean/options/options.rb
193
+ - lib/bakeqac/filter.rb
193
194
  - lib/bakeqac/options/options.rb
194
195
  - lib/bakery/buildPattern.rb
195
196
  - lib/bakery/model/language.rb