Class: SaikuroBuilder

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/saikuro_builder.rb

Overview

Construction de la tache saikuro (complexité cyclomatique du code)
author: Vincent Dubois
date: 08 fevrier 2009

Instance Method Summary collapse

Methods included from Utils

build_name, erb_run, flog_caracteristics, flog_score_to_css_style, percent_to_css_style, run_command, verify_gem_presence

Instance Method Details

#build(project_name, auto_install, proxy_option) ⇒ Object

Implementation de la construction de la tache



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/saikuro_builder.rb', line 10

def build(project_name, auto_install, proxy_option)
  # On verifie la presence de saikuro
  Utils.verify_gem_presence("Saikuro", auto_install, proxy_option)
  # On lance la generation
  puts " Building saikuro report..."
  puts Utils.run_command("saikuro -c -i app -i lib -i test -y 0 -w 5 -e 7 -o #{Continuous4r::WORK_DIR}/saikuro")
  if !File.exist?("#{Continuous4r::WORK_DIR}/saikuro/index_cyclo.html")
    raise " Execution of saikuro with the metric_fu gem failed.\n BUILD FAILED."
  end
  require 'hpricot'
  doc = Hpricot(File.read("#{Continuous4r::WORK_DIR}/saikuro/index_cyclo.html"))
  classes_with_errors = Array.new
  classes_with_warnings = Array.new
  doc.search("//tr") do |tr|
    tds = tr.search("td")
    if tds.length > 0 and tds[2]['class'] == "error" and !(classes_with_errors.include?(tds[0].inner_text))
      classes_with_errors << tds[0].inner_text
    elsif tds.length > 0 and tds[2]['class'] == "warning" and !(classes_with_warnings.include?(tds[0].inner_text))
      classes_with_warnings << tds[0].inner_text
    end
  end
  files = Array.new
  files << Dir.glob("app/**/*.rb")
  files << Dir.glob("lib/**/*.rb")
  files << Dir.glob("test/**/*.rb")
  files.flatten!
  @percent = 100.0 - (((classes_with_errors.length + (classes_with_warnings.length * 0.5)) * 100.0) / files.length.to_f)
end

#quality_indicator_nameObject

Nom de l’indicateur de qualité



45
46
47
# File 'lib/saikuro_builder.rb', line 45

def quality_indicator_name
  "cyclomatic complexity"
end

#quality_percentageObject

Methode qui permet d’extraire le pourcentage de qualité extrait d’un builder



40
41
42
# File 'lib/saikuro_builder.rb', line 40

def quality_percentage
  @percent
end