Module: MetricFu

Extended by:
SingleForwardable
Defined in:
lib/metric_fu/metric.rb,
lib/metric_fu.rb,
lib/metric_fu/io.rb,
lib/metric_fu/run.rb,
lib/metric_fu/loader.rb,
lib/metric_fu/logger.rb,
lib/metric_fu/gem_run.rb,
lib/metric_fu/utility.rb,
lib/metric_fu/version.rb,
lib/metric_fu/reporter.rb,
lib/metric_fu/calculate.rb,
lib/metric_fu/formatter.rb,
lib/metric_fu/generator.rb,
lib/metric_fu/cli/client.rb,
lib/metric_fu/cli/helper.rb,
lib/metric_fu/cli/parser.rb,
lib/metric_fu/constantize.rb,
lib/metric_fu/environment.rb,
lib/metric_fu/gem_version.rb,
lib/metric_fu/configuration.rb,
lib/metric_fu/formatter/html.rb,
lib/metric_fu/formatter/yaml.rb,
lib/metric_fu/formatter/syntax.rb,
lib/metric_fu/reporting/result.rb,
lib/metric_fu/templates/report.rb,
lib/metric_fu/templates/template.rb,
lib/metric_fu/metrics/cane/metric.rb,
lib/metric_fu/metrics/flay/metric.rb,
lib/metric_fu/metrics/flog/metric.rb,
lib/metric_fu/metrics/rcov/metric.rb,
lib/metric_fu/metrics/reek/metric.rb,
lib/metric_fu/metrics/cane/grapher.rb,
lib/metric_fu/metrics/churn/metric.rb,
lib/metric_fu/metrics/flay/grapher.rb,
lib/metric_fu/metrics/flog/grapher.rb,
lib/metric_fu/metrics/rcov/grapher.rb,
lib/metric_fu/metrics/reek/grapher.rb,
lib/metric_fu/metrics/roodi/metric.rb,
lib/metric_fu/metrics/stats/metric.rb,
lib/metric_fu/errors/analysis_error.rb,
lib/metric_fu/metrics/roodi/grapher.rb,
lib/metric_fu/metrics/stats/grapher.rb,
lib/metric_fu/metrics/cane/generator.rb,
lib/metric_fu/metrics/flay/generator.rb,
lib/metric_fu/metrics/flog/generator.rb,
lib/metric_fu/metrics/rcov/generator.rb,
lib/metric_fu/metrics/rcov/rcov_line.rb,
lib/metric_fu/metrics/reek/generator.rb,
lib/metric_fu/metrics/saikuro/metric.rb,
lib/metric_fu/reporting/graphs/graph.rb,
lib/metric_fu/metrics/cane/violations.rb,
lib/metric_fu/metrics/churn/generator.rb,
lib/metric_fu/metrics/hotspots/metric.rb,
lib/metric_fu/metrics/roodi/generator.rb,
lib/metric_fu/metrics/stats/generator.rb,
lib/metric_fu/data_structures/location.rb,
lib/metric_fu/metrics/hotspots/hotspot.rb,
lib/metric_fu/reporting/graphs/grapher.rb,
lib/metric_fu/data_structures/sexp_node.rb,
lib/metric_fu/metrics/saikuro/generator.rb,
lib/metric_fu/metrics/hotspots/generator.rb,
lib/metric_fu/templates/metrics_template.rb,
lib/metric_fu/data_structures/line_numbers.rb,
lib/metric_fu/metrics/rcov/external_client.rb,
lib/metric_fu/metrics/saikuro/scratch_file.rb,
lib/metric_fu/metrics/hotspots/analysis/table.rb,
lib/metric_fu/metrics/saikuro/parsing_element.rb,
lib/metric_fu/metrics/hotspots/analysis/record.rb,
lib/metric_fu/metrics/hotspots/analysis/ranking.rb,
lib/metric_fu/metrics/hotspots/hotspot_analyzer.rb,
lib/metric_fu/metrics/rcov/rcov_format_coverage.rb,
lib/metric_fu/metrics/hotspots/analysis/grouping.rb,
lib/metric_fu/metrics/hotspots/analysis/problems.rb,
lib/metric_fu/metrics/hotspots/analysis/rankings.rb,
lib/metric_fu/metrics/hotspots/analysis/groupings.rb,
lib/metric_fu/metrics/rails_best_practices/metric.rb,
lib/metric_fu/metrics/rails_best_practices/grapher.rb,
lib/metric_fu/metrics/rails_best_practices/generator.rb,
lib/metric_fu/metrics/hotspots/analysis/analyzer_tables.rb,
lib/metric_fu/metrics/hotspots/analysis/analyzed_problems.rb,
lib/metric_fu/metrics/hotspots/analysis/scoring_strategies.rb,
lib/metric_fu/metrics/hotspots/analysis/ranked_problem_location.rb

Overview

Reads and writes external coverage files as BINARY

Defined Under Namespace

Modules: Calculate, CaneViolations, Cli, Constantize, Environment, Formatter, HotspotScoringStrategies, Io, Templates, Utility Classes: AnalysisError, AnalyzerTables, CaneGenerator, CaneGrapher, ChurnGenerator, ChurnHotspot, ClassMethodNode, Configuration, FlayGenerator, FlayGrapher, FlayHotspot, FlogGenerator, FlogGrapher, FlogHotspot, GemRun, GemVersion, Generator, Graph, Grapher, Grouping, Hotspot, HotspotAnalyzedProblems, HotspotAnalyzer, HotspotGroupings, HotspotProblems, HotspotRankedProblemLocation, HotspotRankings, HotspotsGenerator, InstanceMethodNode, LineNumbers, Loader, Location, Logger, MethodContainer, Metric, MetricCane, MetricChurn, MetricFlay, MetricFlog, MetricHotspots, MetricRailsBestPractices, MetricRcov, MetricReek, MetricRoodi, MetricSaikuro, MetricStats, RCovFormatCoverage, RCovLine, RCovTestCoverageClient, RailsBestPracticesGenerator, RailsBestPracticesGrapher, Ranking, RcovGenerator, RcovGrapher, RcovHotspot, Record, ReekGenerator, ReekGrapher, ReekHotspot, Reporter, Result, RoodiGenerator, RoodiGrapher, RoodiHotspot, Run, SaikuroGenerator, SaikuroHotspot, SaikuroParsingElement, SaikuroScratchFile, SexpNode, SingletonMethodNode, StatsGenerator, StatsGrapher, StatsHotspot, Table, Template, Version

Constant Summary collapse

APP_ROOT =
File.expand_path(File.join(File.dirname(__FILE__), ".."))
LIB_ROOT =
File.join(APP_ROOT, "lib/metric_fu")
LOADER =
MetricFu::Loader.new(LIB_ROOT)
LIBRARY_DIRS =
%w(metrics formatter reporting logging errors data_structures tasks)
ARTIFACT_SUBDIRS =
%w(scratch output _data)
VERSION =
[Version::MAJOR, Version::MINOR, Version::PATCH].join(".")

Class Method Summary collapse

Class Method Details

.artifact_dirObject


104
105
106
# File 'lib/metric_fu.rb', line 104

def artifact_dir
  MetricFu::Io::FileSystem.artifact_dir
end

.configurationObject

The @configuration class variable holds a global type configuration object for any parts of the system to use. TODO Configuration should probably be a singleton class


9
10
11
# File 'lib/metric_fu/configuration.rb', line 9

def self.configuration
  @configuration ||= Configuration.new
end

.configureObject


13
14
15
# File 'lib/metric_fu/configuration.rb', line 13

def self.configure
  configuration.tap(&:configure_metrics)
end

.current_timeObject

The time the metrics are generated


76
77
78
# File 'lib/metric_fu.rb', line 76

def current_time
  Time.now.localtime
end

.graphObject


2
3
4
# File 'lib/metric_fu/reporting/graphs/graph.rb', line 2

def self.graph
  @graph ||= Graph.new
end

.lib_dirObject


84
85
86
# File 'lib/metric_fu.rb', line 84

def lib_dir
  LIB_ROOT
end

.loaderObject


90
91
92
# File 'lib/metric_fu.rb', line 90

def loader
  LOADER
end

.loggerObject


4
5
6
# File 'lib/metric_fu/logger.rb', line 4

def self.logger
  @logger ||= ::MetricFu::Logger.new($stdout)
end

.metric_nameObject


19
20
21
# File 'lib/metric_fu.rb', line 19

def metric_name
  "MetricFu"
end

.metric_urlObject


15
16
17
# File 'lib/metric_fu.rb', line 15

def metric_url
  "https://github.com/metricfu/metric_fu"
end

.report_date_stringObject


57
58
59
# File 'lib/metric_fu.rb', line 57

def report_date_string
  report_time.strftime("%Y%m%d")
end

.report_fingerprintObject

Non-date-specific; Used to uniquely identify a report run


71
72
73
# File 'lib/metric_fu.rb', line 71

def report_fingerprint
  report_time.to_i.to_s
end

.report_idString

Used to uniquely identify reports as a sortable reference to when the report was generated

Examples:

'20140323'

Returns:

  • (String)

66
67
68
# File 'lib/metric_fu.rb', line 66

def report_id
  report_date_string
end

.report_nameObject


44
45
46
# File 'lib/metric_fu.rb', line 44

def report_name
  @report_name || self.report_name = run_path.basename.to_s
end

.report_name=(report_name) ⇒ Object


48
49
50
# File 'lib/metric_fu.rb', line 48

def report_name=(report_name)
  @report_name = report_name
end

.report_timeObject

The time at analyzed code state


53
54
55
# File 'lib/metric_fu.rb', line 53

def report_time
  Time.now
end

.resetObject


114
115
116
117
118
119
120
121
# File 'lib/metric_fu.rb', line 114

def reset
  # TODO Don't like how this method needs to know
  # all of these class variables that are defined
  # in separate classes.
  @configuration = nil
  @graph = nil
  @result = nil
end

.resultObject

MetricFu.result memoizes access to a Result object, that will be used throughout the lifecycle of the MetricFu app.


4
5
6
# File 'lib/metric_fu/reporting/result.rb', line 4

def self.result
  @result ||= Result.new
end

.rootObject


11
12
13
# File 'lib/metric_fu.rb', line 11

def root
  @app_root ||= Pathname(APP_ROOT)
end

.root_dirObject


80
81
82
# File 'lib/metric_fu.rb', line 80

def root_dir
  APP_ROOT
end

.run(options) ⇒ Object


123
124
125
# File 'lib/metric_fu.rb', line 123

def run(options)
  MetricFu::Run.new.run(options)
end

.run_dirObject


32
33
34
# File 'lib/metric_fu.rb', line 32

def run_dir
  @run_dir ||= Dir.pwd
end

.run_dir=(run_dir) ⇒ Object


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

def run_dir=(run_dir)
  @run_dir = run_dir
end

.run_only(metrics_to_run_names, options) ⇒ Object


127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/metric_fu.rb', line 127

def run_only(metrics_to_run_names, options)
  metrics_to_run_names = Array(metrics_to_run_names).map(&:to_s)
  MetricFu::Configuration.run do |config|
    config.configure_metrics.each do |metric|
      metric_name = metric.name.to_s
      if metrics_to_run_names.include?(metric_name)
        p "Enabling #{metric_name}"
        metric.enabled = true
      else
        p "Disabling #{metric_name}"
        metric.enabled = false
      end
    end
  end
  run(options)
end

.run_pathObject


36
37
38
# File 'lib/metric_fu.rb', line 36

def run_path
  Pathname(run_dir)
end

.with_run_dir(dir, &block) ⇒ Object


23
24
25
26
27
28
29
30
# File 'lib/metric_fu.rb', line 23

def with_run_dir(dir, &block)
  old_dir = run_dir
  self.run_dir = dir

  block.call

  self.run_dir = old_dir
end