mezis/appfab

View on GitHub

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

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

            def set_order_from_params_and_angle
              session[:ideas_order] ||= {}
              params[:order] =
              session[:ideas_order][@angle] = begin
                (VALID_ORDERS.include?(params[:order])                and params[:order]) ||
          Severity: Minor
          Found in app/controllers/ideas_controller.rb and 1 other location - About 45 mins to fix
          app/controllers/ideas_controller.rb on lines 216..223

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

          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

            def set_filter_from_params_and_angle
              session[:ideas_filter] ||= {}
              params[:filter] =
              session[:ideas_filter][@angle] = begin
                (VALID_FILTERS.include?(params[:filter])                and params[:filter]) ||
          Severity: Minor
          Found in app/controllers/ideas_controller.rb and 1 other location - About 45 mins to fix
          app/controllers/ideas_controller.rb on lines 206..213

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

          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

          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

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

            def set_angle_from_params
              params[:angle] =
              session[:ideas_angle] = begin
                (VALID_ANGLES.include?(params[:angle])        and params[:angle]) ||
                (VALID_ANGLES.include?(session[:ideas_angle]) and session[:ideas_angle]) ||
          Severity: Minor
          Found in app/controllers/ideas_controller.rb and 1 other location - About 30 mins to fix
          app/controllers/ideas_controller.rb on lines 196..203

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

          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

            def set_view_from_params
              params[:view] =
              session[:ideas_view] = begin
                (VALID_VIEWS.include?(params[:view])        and params[:view]) ||
                (VALID_VIEWS.include?(session[:ideas_view]) and session[:ideas_view]) ||
          Severity: Minor
          Found in app/controllers/ideas_controller.rb and 1 other location - About 30 mins to fix
          app/controllers/ideas_controller.rb on lines 186..193

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

          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

            def after_create(vetting)
              return unless vetting.idea # happens in a few tests
              vetting.idea.participants.each do |user|
                next if user == vetting.user # don't get notified for my own vettings
                Notification::NewVetting.create! recipient:user, subject:vetting
          Severity: Minor
          Found in app/observers/notification/vetting_observer.rb and 1 other location - About 25 mins to fix
          app/observers/notification/comment_observer.rb on lines 5..13

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

          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

            def after_create(record)
              return unless record.idea # happens in tests
              record.idea.participants.each do |user|
                next if user == record.author # don't get notified for my own comments
                Notification::NewComment.create! subject:record, recipient:user
          Severity: Minor
          Found in app/observers/notification/comment_observer.rb and 1 other location - About 25 mins to fix
          app/observers/notification/vetting_observer.rb on lines 5..13

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

          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

          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

          Severity
          Category
          Status
          Source
          Language