mbleigh/acts-as-taggable-on

View on GitHub

Showing 15 of 21 total issues

Method save_tags has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

      def save_tags
        tagging_contexts.each do |context|
          next unless tag_list_cache_set_on(context)

          # List of currently assigned tag names
Severity: Minor
Found in lib/acts_as_taggable_on/taggable/core.rb - About 3 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

Method save_owned_tags has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def save_owned_tags
        tagging_contexts.each do |context|
          cached_owned_tag_list_on(context).each do |owner, tag_list|
            # Find existing tags or create non-existing tags:
            tags = find_or_create_tags_from_list_with_context(tag_list.uniq, context)
Severity: Minor
Found in lib/acts_as_taggable_on/taggable/ownership.rb - About 2 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

Method initialize_acts_as_taggable_on_core has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize_acts_as_taggable_on_core
          include taggable_mixin
          tag_types.map(&:to_s).each do |tags_type|
            tag_type = tags_type.to_s.singularize
            context_taggings = "#{tag_type}_taggings".to_sym
Severity: Minor
Found in lib/acts_as_taggable_on/taggable/core.rb - About 1 hr to fix

    Method find_or_create_all_with_like_by_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.find_or_create_all_with_like_by_name(*list)
          list = Array(list).flatten
    
          return [] if list.empty?
    
    
    Severity: Minor
    Found in lib/acts_as_taggable_on/tag.rb - About 1 hr 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

    Method tag has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def tag(taggable, opts = {})
            opts.reverse_merge!(force: true)
            skip_save = opts.delete(:skip_save)
            return false unless taggable.respond_to?(:is_taggable?) && taggable.is_taggable?
    
    
    Severity: Minor
    Found in lib/acts_as_taggable_on/tagger.rb - About 1 hr 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

    Method save_owned_tags has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def save_owned_tags
            tagging_contexts.each do |context|
              cached_owned_tag_list_on(context).each do |owner, tag_list|
                # Find existing tags or create non-existing tags:
                tags = find_or_create_tags_from_list_with_context(tag_list.uniq, context)
    Severity: Minor
    Found in lib/acts_as_taggable_on/taggable/ownership.rb - About 1 hr to fix

      Method save_tags has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def save_tags
              tagging_contexts.each do |context|
                next unless tag_list_cache_set_on(context)
      
                # List of currently assigned tag names
      Severity: Minor
      Found in lib/acts_as_taggable_on/taggable/core.rb - About 1 hr to fix

        Method all_tag_counts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def all_tag_counts(options = {})
                  options = options.dup
                  options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :on, :id
        
                  ## Generate conditions:
        Severity: Minor
        Found in lib/acts_as_taggable_on/taggable/collection.rb - About 1 hr to fix

          Method tagging_conditions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def tagging_conditions(options)
                    tagging_conditions = []
                    if options[:end_at]
                      tagging_conditions.push sanitize_sql(["#{ActsAsTaggableOn::Tagging.table_name}.created_at <= ?",
                                                            options.delete(:end_at)])
          Severity: Minor
          Found in lib/acts_as_taggable_on/taggable/collection.rb - About 1 hr to fix

            Method build has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def self.build(taggable_model, tag_model, tagging_model, tag_list, options)
            Severity: Minor
            Found in lib/acts_as_taggable_on/taggable/tagged_with_query.rb - About 35 mins to fix

              Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def initialize(taggable_model, tag_model, tagging_model, tag_list, options)
              Severity: Minor
              Found in lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb - About 35 mins to fix

                Method all_tag_counts has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def all_tag_counts(options = {})
                          options = options.dup
                          options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :on, :id
                
                          ## Generate conditions:
                Severity: Minor
                Found in lib/acts_as_taggable_on/taggable/collection.rb - About 35 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

                Method tagging_conditions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                        def tagging_conditions(options)
                          tagging_conditions = []
                          if options[:end_at]
                            tagging_conditions.push sanitize_sql(["#{ActsAsTaggableOn::Tagging.table_name}.created_at <= ?",
                                                                  options.delete(:end_at)])
                Severity: Minor
                Found in lib/acts_as_taggable_on/taggable/collection.rb - About 35 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

                Method to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def to_s
                      tags = frozen? ? dup : self
                      tags.send(:clean!)
                
                      tags.map do |name|
                Severity: Minor
                Found in lib/acts_as_taggable_on/tag_list.rb - About 35 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

                Method remove_unused_tags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    def remove_unused_tags
                      if ActsAsTaggableOn.remove_unused_tags
                        if ActsAsTaggableOn.tags_counter
                          tag.destroy if tag.reload.taggings_count.zero?
                        elsif tag.reload.taggings.none?
                Severity: Minor
                Found in lib/acts_as_taggable_on/tagging.rb - About 35 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

                Severity
                Category
                Status
                Source
                Language