pboling/an_axe

View on GitHub
app/controllers/an_axe/forums/topics_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

There are no issues that match your filters.

Category
Status