otwcode/otwarchive

View on GitHub
app/models/tagset_models/owned_tag_set.rb

Summary

Maintainability
C
1 day
Test Coverage

Method load_batch_associations! has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

  def load_batch_associations!(batch_associations, options = {})
    options.reverse_merge!({do_relationships: false})
    association_lines = batch_associations.split("\n")
    fandom_tagnames_to_add = []
    child_tagnames_to_add = []
Severity: Minor
Found in app/models/tagset_models/owned_tag_set.rb - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Class OwnedTagSet has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class OwnedTagSet < ApplicationRecord
  # Rather than use STI or polymorphic associations, since really what we want to do here
  # is build an extra layer of functionality on top of the generic tag set structure,
  # I've gone with creating a separate model and making it contain a generic tag set
  # as a member. This way we don't have to duplicate the tag set code or functionality
Severity: Minor
Found in app/models/tagset_models/owned_tag_set.rb - About 3 hrs to fix

    Method load_batch_associations! has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def load_batch_associations!(batch_associations, options = {})
        options.reverse_merge!({do_relationships: false})
        association_lines = batch_associations.split("\n")
        fandom_tagnames_to_add = []
        child_tagnames_to_add = []
    Severity: Minor
    Found in app/models/tagset_models/owned_tag_set.rb - About 1 hr to fix

      Method owner_changes= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def owner_changes=(pseud_list)
          Pseud.parse_bylines(pseud_list)[:pseuds].each do |pseud|
            if self.owners.include?(pseud)
              self.owners -= [pseud] if self.owners.count > 1
            else
      Severity: Minor
      Found in app/models/tagset_models/owned_tag_set.rb - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      There are no issues that match your filters.

      Category
      Status