pboling/an_axe

View on GitHub

Showing 15 of 15 total issues

Method configure has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def self.configure(&block)
      yield @@settings

      #Validate configuration right then and there...
      unless self.settings[:user_class].respond_to?(:constantize) && user_klass = self.settings[:user_class].constantize && defined?(user_klass)
Severity: Minor
Found in lib/an_axe/config.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 show has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

      def show
        respond_to do |format|
          format.html do
            # see notes in application.rb on how this works
            update_last_seen_at
Severity: Minor
Found in app/controllers/an_axe/forums/topics_controller.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 verbose has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.verbose(maximum_level)
    return false if AnAxe.config.verbose == false
    return case maximum_level
      when :low     then AnAxe::Config.verbose == :low
      when :med     then AnAxe::Config.settings[:verbose_inclusive] ? [:med, :low].include?(AnAxe::Config.verbose) : AnAxe::Config.verbose == :med
Severity: Minor
Found in lib/an_axe.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 create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def create
        @topic = Topic.find_by_id_and_forum_id(params[:topic_id],params[:forum_id])
        if @topic.locked?
          respond_to do |format|
            format.html do
Severity: Minor
Found in app/controllers/an_axe/forums/posts_controller.rb - About 1 hr to fix

    Method show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def show
          respond_to do |format|
            format.html do
              # keep track of when we last viewed this forum for activity indicators
              (session[:forums] ||= {})[@forum.id] = Time.now.utc if logged_in?
    Severity: Minor
    Found in app/controllers/an_axe/forums_controller.rb - About 45 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 search_posts_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def search_posts_path(rss = false)
          options = params[:q].blank? ? {} : {:q => params[:q]}
          options[:format] = 'rss' if rss
          [[:user, :user_id], [:forum, :forum_id]].each do |(route_key, param_key)|
            return send("#{route_key}_posts_path", options.update(param_key => params[param_key])) if params[param_key]
    Severity: Minor
    Found in app/helpers/an_axe/application_helper.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 assign_protected has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def assign_protected
              @topic.send("#{AnAxe::Config.user_relation}=", current_user) if @topic.new_record?
              # admins and moderators can sticky and lock topics
              return unless admin? or current_user.moderator_of?(@topic.forum)
              @topic.sticky, @topic.locked = params[:topic][:sticky], params[:topic][:locked]
    Severity: Minor
    Found in app/controllers/an_axe/forums/topics_controller.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def create
            topic_saved, post_saved = false, false
            # this is icky - move the topic/first post workings into the topic model?
            AmAxe::Topic.transaction do
              @topic  = @forum.topics.build(params[:topic])
    Severity: Minor
    Found in app/controllers/an_axe/forums/topics_controller.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def create
            @topic = Topic.find_by_id_and_forum_id(params[:topic_id],params[:forum_id])
            if @topic.locked?
              respond_to do |format|
                format.html do
    Severity: Minor
    Found in app/controllers/an_axe/forums/posts_controller.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 search_posts_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def search_posts_title
          returning(params[:q].blank? ? t('savage_beast.recent_posts') : t("savage_beast.searching_for") + " '#{h params[:q]}'") do |title|
            title << " "+'by {user}'[:by_user,h(User.find(params[:user_id]).display_name)] if params[:user_id]
            title << " "+'in {forum}'[:in_forum,h(Forum.find(params[:forum_id]).name)] if params[:forum_id]
          end
    Severity: Minor
    Found in app/helpers/an_axe/application_helper.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

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

          unless self.settings[:user_scope_class].respond_to?(:constantize) && user_scope_klass = self.settings[:user_scope_class].constantize && defined?(user_scope_klass)
            raise InvalidConfiguration, "AnAxe::Config.settings[:user_scope_class] is invalid: #{self.settings[:user_scope_class]} cannot be constantized, or is not defined."
          end
    Severity: Minor
    Found in lib/an_axe/config.rb and 2 other locations - About 15 mins to fix
    lib/an_axe/config.rb on lines 73..75
    lib/an_axe/config.rb on lines 85..87

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 26.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

          unless self.settings[:user_class].respond_to?(:constantize) && user_klass = self.settings[:user_class].constantize && defined?(user_klass)
            raise InvalidConfiguration, "AnAxe::Config.settings[:user_class] is invalid: #{self.settings[:user_class]} cannot be constantized, or is not defined."
          end
    Severity: Minor
    Found in lib/an_axe/config.rb and 2 other locations - About 15 mins to fix
    lib/an_axe/config.rb on lines 76..78
    lib/an_axe/config.rb on lines 85..87

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 26.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

          unless self.settings[:forum_scope_class].respond_to?(:constantize) && forum_scope_klass = self.settings[:forum_scope_class].constantize && defined?(forum_scope_klass)
            raise InvalidConfiguration, "AnAxe::Config.settings[:forum_scope_class] is invalid: #{self.settings[:forum_scope_class]} cannot be constantized, or is not defined."
          end
    Severity: Minor
    Found in lib/an_axe/config.rb and 2 other locations - About 15 mins to fix
    lib/an_axe/config.rb on lines 73..75
    lib/an_axe/config.rb on lines 76..78

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 26.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          if (defined?(forum_scope_klass) && !self.settings[:forum_scoped_method].is_a?(Symbol)) || (self.settings[:forum_scoped_method].is_a?(Symbol) && !(defined?(forum_scope_klass)))
            raise InvalidConfiguration, "AnAxe::Config.settings[:forum_scope_class] and AnAxe::Config.settings[:forum_scoped_method] must both be set if either is set."
          end
    Severity: Minor
    Found in lib/an_axe/config.rb and 1 other location - About 15 mins to fix
    lib/an_axe/config.rb on lines 82..84

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          if (defined?(user_scope_klass) && !self.settings[:user_scoped_method].is_a?(Symbol)) || (self.settings[:user_scoped_method].is_a?(Symbol) && !(defined?(user_scope_klass)))
            raise InvalidConfiguration, "AnAxe::Config.settings[:user_scope_class] and AnAxe::Config.settings[:user_scoped_method] must both be set if either is set."
          end
    Severity: Minor
    Found in lib/an_axe/config.rb and 1 other location - About 15 mins to fix
    lib/an_axe/config.rb on lines 91..93

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language