mezis/appfab

View on GitHub

Showing 17 of 23 total issues

Method initialize has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(user)
    user ||= User.new

    # Idea permissions
    draft_or_submitted = [:draft, :submitted].map { |sym| IdeaStateMachine.state_value(sym) }
Severity: Major
Found in app/models/ability.rb - About 3 hrs to fix

    Class Idea has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Idea < ActiveRecord::Base
      # attr_accessible :title, :problem, :solution, :metrics, :deadline, :author, :design_size, :development_size, :rating, :category, :product_manager, :active_at
    
      belongs_to :author, :class_name => 'User'
      belongs_to :account
    Severity: Minor
    Found in app/models/idea.rb - About 2 hrs to fix

      Class IdeasController has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class IdeasController < ApplicationController
        include Traits::RequiresLogin
      
        before_filter :require_account!
        before_filter :cleanup_session
      Severity: Minor
      Found in app/controllers/ideas_controller.rb - About 2 hrs to fix

        Method initialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def initialize(user)
            user ||= User.new
        
            # Idea permissions
            draft_or_submitted = [:draft, :submitted].map { |sym| IdeaStateMachine.state_value(sym) }
        Severity: Minor
        Found in app/models/ability.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 votes_message has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def votes_message(record, action)
            if record.subject.kind_of?(Idea)
              case action
                when :ok     then _('You have endorsed the idea.')
                when :fail   then _('Failed to endorse the idea.')
        Severity: Minor
        Found in app/helpers/votes_helper.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 idea_copy_for_state has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def idea_copy_for_state(state_name)
            case state_name
            when :archived
              _("This idea is archived: It has been moved out of the stack to make way for other ideas.")
            when :graveyarded
        Severity: Minor
        Found in app/helpers/ideas_helper.rb - About 1 hr to fix

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

            def create
              @comment = Comment.new(comment_params)
              @comment.author = current_user
              authorize! :create, @comment if @comment.valid?
          
          
          Severity: Minor
          Found in app/controllers/comments_controller.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

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

            def update
              @idea = find_idea(params[:id])
          
              # specifics on account change
              if new_account_id = idea_params.delete(:account_id)
          Severity: Minor
          Found in app/controllers/ideas_controller.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

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

            def index
              @angle    = set_angle_from_params
              @order    = set_order_from_params_and_angle
              @filter   = set_filter_from_params_and_angle
              @category = set_category_from_params_and_angle
          Severity: Minor
          Found in app/controllers/ideas_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 act_as_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def act_as_user(user_id)
              assumed_user = current_account.users.find_by_id(user_id)
              unless assumed_user
                flash[:error] = _("Oops, we could not find the user you're trying to act as.")
                return
          Severity: Minor
          Found in app/controllers/sessions_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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              notifications = if params[:id] == 'all'
                current_user.notifications
              else
                current_user.notifications.where(id: params[:id].to_i)
          Severity: Minor
          Found in app/controllers/notifications_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 after_create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def after_create(record)
              return unless record.subject # happens in a few tests
              case record.subject
              when Comment
                Notification::NewVoteOnComment.create! recipient:record.subject.author, subject:record
          Severity: Minor
          Found in app/observers/notification/vote_observer.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 can_link_to has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def can_link_to(*args, &block)
              options = args.last { |arg| arg.kind_of?(Hash) }.dup
          
              auth_criteria  = options.delete(:auth)
              auth_condition = auth_criteria.nil? ? true : can?(*auth_criteria)
          Severity: Minor
          Found in app/helpers/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 idea_unavailable_action_tooptip has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def idea_unavailable_action_tooptip(idea, state)
              if idea.is_state_in_future?(state)
                case state
                when :vetted
                  s_('Tooltip|This idea cannot be vetted yet.')
          Severity: Minor
          Found in app/helpers/ideas_helper.rb - About 25 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 after_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def after_save(record)
              return unless record.account && record.account_id_changed?
              record.account.users.each do |account_user|
                next if account_user == record # don't get notified when I join
                Notification::NewUser.create!(recipient:account_user, subject:record)
          Severity: Minor
          Found in app/observers/notification/user_observer.rb - About 25 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 set_category_from_params_and_angle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_category_from_params_and_angle
              session[:ideas_category] ||= {}
              params[:category] =
              session[:ideas_category][@angle] = begin
                valid_categories = (current_user.account.andand.categories || []) + %w(all none)
          Severity: Minor
          Found in app/controllers/ideas_controller.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              idea = current_account.ideas.find(params[:user_bookmark][:idea_id])
              @user_bookmark = current_user.bookmarks.new(idea: idea)
              if @user_bookmark.save
                flash[:success] = _('Bookmark successfuly added.')
          Severity: Minor
          Found in app/controllers/user/bookmarks_controller.rb - About 25 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