CLOSER-Cohorts/archivist

View on GitHub
app/models/map.rb

Summary

Maintainability
A
0 mins
Test Coverage

Cyclomatic complexity for resolved_topic_conflict is too high. [7/6]
Open

  def resolved_topic_conflict
    return if variable.nil? || source.nil? || variable.derived? || source.resolved_topic.nil? || variable.resolved_topic.nil?
    if source.resolved_topic != variable.resolved_topic
      errors.add(:topic, I18n.t('activerecord.errors.models.map.attributes.resolved_topic.variables_conflict', variable: variable, source: source, variable_topic: variable.resolved_topic, source_topic: source.resolved_topic))
    end
Severity: Minor
Found in app/models/map.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

There are no issues that match your filters.

Category
Status