Class: FeatureMap::Private::HealthCalculator
- Inherits:
-
Object
- Object
- FeatureMap::Private::HealthCalculator
- Defined in:
- lib/feature_map/private/health_calculator.rb
Instance Attribute Summary collapse
-
#cyclomatic_complexity_config ⇒ Object
readonly
Returns the value of attribute cyclomatic_complexity_config.
-
#encapsulation_config ⇒ Object
readonly
Returns the value of attribute encapsulation_config.
-
#percentile_metrics ⇒ Object
readonly
Returns the value of attribute percentile_metrics.
-
#test_coverage_config ⇒ Object
readonly
Returns the value of attribute test_coverage_config.
-
#todo_count_config ⇒ Object
readonly
Returns the value of attribute todo_count_config.
Instance Method Summary collapse
- #health_score_for(feature_name) ⇒ Object
-
#initialize(percentile_metrics:, health_config:) ⇒ HealthCalculator
constructor
A new instance of HealthCalculator.
Constructor Details
#initialize(percentile_metrics:, health_config:) ⇒ HealthCalculator
Returns a new instance of HealthCalculator.
9 10 11 12 13 14 15 |
# File 'lib/feature_map/private/health_calculator.rb', line 9 def initialize(percentile_metrics:, health_config:) @percentile_metrics = percentile_metrics @cyclomatic_complexity_config = health_config['components']['cyclomatic_complexity'] @encapsulation_config = health_config['components']['encapsulation'] @test_coverage_config = health_config['components']['test_coverage'] @todo_count_config = health_config['components']['todo_count'] end |
Instance Attribute Details
#cyclomatic_complexity_config ⇒ Object (readonly)
Returns the value of attribute cyclomatic_complexity_config.
7 8 9 |
# File 'lib/feature_map/private/health_calculator.rb', line 7 def cyclomatic_complexity_config @cyclomatic_complexity_config end |
#encapsulation_config ⇒ Object (readonly)
Returns the value of attribute encapsulation_config.
7 8 9 |
# File 'lib/feature_map/private/health_calculator.rb', line 7 def encapsulation_config @encapsulation_config end |
#percentile_metrics ⇒ Object (readonly)
Returns the value of attribute percentile_metrics.
7 8 9 |
# File 'lib/feature_map/private/health_calculator.rb', line 7 def percentile_metrics @percentile_metrics end |
#test_coverage_config ⇒ Object (readonly)
Returns the value of attribute test_coverage_config.
7 8 9 |
# File 'lib/feature_map/private/health_calculator.rb', line 7 def test_coverage_config @test_coverage_config end |
#todo_count_config ⇒ Object (readonly)
Returns the value of attribute todo_count_config.
7 8 9 |
# File 'lib/feature_map/private/health_calculator.rb', line 7 def todo_count_config @todo_count_config end |
Instance Method Details
#health_score_for(feature_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/feature_map/private/health_calculator.rb', line 17 def health_score_for(feature_name) test_coverage_component = test_coverage_component_for(feature_name) cyclomatic_complexity_component = cyclomatic_complexity_component_for(feature_name) encapsulation_component = encapsulation_component_for(feature_name) todo_count_component = todo_count_component_for(feature_name) overall = [ test_coverage_component, cyclomatic_complexity_component, encapsulation_component, todo_count_component ].sum { |c| c['health_score'] } total_weight = [ cyclomatic_complexity_config, encapsulation_config, test_coverage_config, todo_count_config ].sum { |c| c['weight'] } { 'test_coverage_component' => test_coverage_component, 'cyclomatic_complexity_component' => cyclomatic_complexity_component, 'encapsulation_component' => encapsulation_component, 'todo_count_component' => todo_count_component, 'overall' => overall / total_weight * 100 } end |