module Reviser::Criteria::CodeAnalysis

@author Renan Strauss

Basic criteria

Public Instance Methods

all_files() click to toggle source

@return project’s directory contents

# File lib/reviser/criteria/code_analysis.rb, line 36
def all_files
        files.join("\r")
end
comments_count() click to toggle source

@return the number of lines of comments

# File lib/reviser/criteria/code_analysis.rb, line 62
def comments_count
        tab_comments = sources.inject([]) { |t, f| t << IO.read(f).scrub.scan(Cfg[:regex_comments]) }
        lines = tab_comments.inject('') { |s, comm| s << find_comments(comm) }.split "\n"

        lines.size
end
find_comments(comm) click to toggle source

Translates a sub-match returned by scan into raw comments string

# File lib/reviser/criteria/code_analysis.rb, line 73
def find_comments(comm)
        comm.inject('') { |t, l| t << l.detect { |a| (a != nil) && !a.strip.empty? } + "\n" }
end
lines_count() click to toggle source

@return the total amount of lines of code

# File lib/reviser/criteria/code_analysis.rb, line 51
def lines_count
        count = sources.inject(0) { |sum, f|
                sum + File.open(f).readlines.select { |l| !l.chomp.empty? }.size
        }

        count - comments_count # FIXME
end
src_files() click to toggle source

@return all files matching the

extenstion language list (note that Cfg[:extension] must be an array)
# File lib/reviser/criteria/code_analysis.rb, line 44
def src_files
        sources.join("\r")
end