pboling/an_axe

View on GitHub

Showing 10 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

    Severity
    Category
    Status
    Source
    Language