Sha256: 2c021960ffd540ee9f632a2c9bd756bcdff5ad46018961a069540edd808337f7
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require "rubycritic/smell" module Rubycritic module SmellAdapter class Flog HIGH_COMPLEXITY_SCORE_THRESHOLD = 25 VERY_HIGH_COMPLEXITY_SCORE_THRESHOLD = 60 def initialize(flog) @flog = flog end def smells smells = [] @flog.each_by_score do |class_method, original_score| score = original_score.round smells << create_smell(class_method, score) if score >= HIGH_COMPLEXITY_SCORE_THRESHOLD end smells end private def create_smell(context, score) Smell.new( :locations => smell_locations(context), :context => context, :message => "has a flog score of #{score}", :score => score, :type => type(score) ) end def smell_locations(context) line = @flog.method_locations[context] file_path, file_line = line.split(":") [Location.new(file_path, file_line)] end def type(score) if score >= VERY_HIGH_COMPLEXITY_SCORE_THRESHOLD "VeryHighComplexity" else "HighComplexity" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubycritic-0.0.10 | lib/rubycritic/smell_adapters/flog.rb |