Class: CodeKeeper::Metrics::AbcMetric
- Inherits:
-
Object
- Object
- CodeKeeper::Metrics::AbcMetric
- Includes:
- RuboCop::Cop::Metrics::Utils::IteratingBlock, RuboCop::Cop::Metrics::Utils::RepeatedCsendDiscount
- Defined in:
- lib/code_keeper/metrics/abc_metric.rb
Overview
Caluculate cyclomatic complexity
Instance Method Summary collapse
-
#initialize(file_path) ⇒ AbcMetric
constructor
A new instance of AbcMetric.
- #score ⇒ Object
Constructor Details
Instance Method Details
#score ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/code_keeper/metrics/abc_metric.rb', line 19 def score caluculator = ::RuboCop::Cop::Metrics::Utils::AbcSizeCalculator.new(@body) caluculator.calculate @assignments = caluculator.instance_variable_get('@assignment') @conditionals = caluculator.instance_variable_get('@condition') @branches = caluculator.instance_variable_get('@branch') value = Math.sqrt(@assignments**2 + @branches**2 + @conditionals**2).round(4) { "#{@path}": value } end |