Class: ReekBuilder
Instance Method Summary collapse
-
#build(project_name, auto_install, proxy_option) ⇒ Object
Implementation de la construction de la tache.
-
#quality_indicator_name ⇒ Object
Nom de l’indicateur de qualité.
-
#quality_percentage ⇒ Object
Methode qui permet d’extraire le pourcentage de qualité extrait d’un builder.
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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/reek_builder.rb', line 27 def build(project_name, auto_install, proxy_option) # On verifie la presence de reek Utils.verify_gem_presence("reek", auto_install, proxy_option) # On lance la generation puts " Building reek report..." files = Array.new files << Dir.glob("app/controllers/*.rb") files << Dir.glob("app/helpers/*.rb") files << Dir.glob("app/models/*.rb") files << Dir.glob("lib/**/*.rb") files << Dir.glob("test/**/*.rb") files.flatten! reek_command = "reek" files.each do |file| reek_command += " '#{file}'" end reek_result = Utils.run_command(reek_command) matches = reek_result.chomp.split("\n\n").map{|m| m.split("\n") } FileUtils.mkdir("#{Continuous4r::WORK_DIR}/reek") reek_file = File.open("#{Continuous4r::WORK_DIR}/reek/index.html","w") count = 0 score = 0.0 matches.each do |match| smells = Array.new match[1..-1].each do |filename| smells << filename if filename.index("[Duplication]").nil? end if smells.length > 0 reek_file.write("<tr class='#{count % 2 == 0 ? "a" : "b"}'>") reek_file.write("<td><a href='xdoclet/#{match.first.split("\"")[1].gsub(/\//,'_')}.html' target='_blank'>#{match.first.split("\"")[1]}</a> -- #{smells.length} warning#{"s" if smells.length > 1}</td><td>") if smells.length > 10 score += 1.0 else score += 0.5 end smells.each do |smell| reek_file.write("#{smell}<br/>") end reek_file.write("</td></tr>") count += 1 end end reek_file.close @percent = 100 - ((score * files.length) / 100) end |
#quality_indicator_name ⇒ Object
Nom de l’indicateur de qualité
79 80 81 |
# File 'lib/reek_builder.rb', line 79 def quality_indicator_name "code smells" end |
#quality_percentage ⇒ Object
Methode qui permet d’extraire le pourcentage de qualité extrait d’un builder
74 75 76 |
# File 'lib/reek_builder.rb', line 74 def quality_percentage @percent end |