volontariat/voluntary

View on GitHub
lib/voluntary/navigation.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method menu_code has a Cognitive Complexity of 463 (exceeds 5 allowed). Consider refactoring.
Open

    def self.menu_code(resource)
      case resource
      when :areas
        Proc.new do |primary, options|
          primary.item :areas, I18n.t('areas.index.title'), areas_path do |areas|
Severity: Minor
Found in lib/voluntary/navigation.rb - About 1 wk 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 menu_code has 218 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.menu_code(resource)
      case resource
      when :areas
        Proc.new do |primary, options|
          primary.item :areas, I18n.t('areas.index.title'), areas_path do |areas|
Severity: Major
Found in lib/voluntary/navigation.rb - About 1 day to fix

    File navigation.rb has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Voluntary
      module Navigation
        class Base
          @@products = {}
          @@core_menus = [:areas, :products, :organizations, :projects, :users, :workflow, :authentication]
    Severity: Minor
    Found in lib/voluntary/navigation.rb - About 2 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                              unless (@task.new_record? rescue true)
      Severity: Major
      Found in lib/voluntary/navigation.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                      comments.item(:new, I18n.t('general.new'), new_story_comment_path(@story)) if @comment
        Severity: Major
        Found in lib/voluntary/navigation.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if can? :destroy, @task
                                        task.item :destroy, I18n.t('general.destroy'), task_path(@task), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
                                      end
          Severity: Major
          Found in lib/voluntary/navigation.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                          unless (@result.new_record? rescue true)
                                            results.item(:show, @result.name, result_path(@result)) do |result|
                                              if can? :destroy, @result
                                                result.item :destroy, I18n.t('general.destroy'), result_path(@result), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
                                              end
            Severity: Major
            Found in lib/voluntary/navigation.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                            if @comment.try(:id) && can?(:edit, @comment)
                                              comments.item(:edit, I18n.t('general.edit'), edit_comment_path(@comment))
                                            end
              Severity: Major
              Found in lib/voluntary/navigation.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            task.item :edit, I18n.t('general.edit'), edit_task_path(@task) if can? :edit, @task
                Severity: Major
                Found in lib/voluntary/navigation.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                            unless (@task.new_record? rescue true)
                  Severity: Major
                  Found in lib/voluntary/navigation.rb - About 45 mins to fix

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

                          when :products 
                            Proc.new do |primary, options|
                              primary.item :products, I18n.t('products.index.title'), products_path do |products|
                                products.item :new, I18n.t('general.new'), new_product_path
                                
                    Severity: Major
                    Found in lib/voluntary/navigation.rb and 1 other location - About 2 hrs to fix
                    lib/voluntary/navigation.rb on lines 105..122

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

                    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

                          when :organizations
                            Proc.new do |primary, options|
                              primary.item :organizations, I18n.t('organizations.index.title'), organizations_path do |organizations|
                                organizations.item :new, I18n.t('general.new'), new_organization_path
                                
                    Severity: Major
                    Found in lib/voluntary/navigation.rb and 1 other location - About 2 hrs to fix
                    lib/voluntary/navigation.rb on lines 82..100

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

                    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

                                                task.item :comments, I18n.t('comments.index.title'), "#{story_path(@story)}#comments" do |comments|
                                                  comments.item(:new, I18n.t('general.new'), new_story_comment_path(@story)) if @comment
                                                  
                                                  if @comment.try(:id) && can?(:edit, @comment)
                                                    comments.item(:edit, I18n.t('general.edit'), edit_comment_path(@comment))
                    Severity: Major
                    Found in lib/voluntary/navigation.rb and 2 other locations - About 45 mins to fix
                    lib/voluntary/navigation.rb on lines 206..211
                    lib/voluntary/navigation.rb on lines 221..226

                    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 3 locations. Consider refactoring.
                    Open

                                          story.item :comments, I18n.t('comments.index.title'), "#{story_path(@story)}#comments" do |comments|
                                            comments.item(:new, I18n.t('general.new'), new_story_comment_path(@story)) if @comment
                                            
                                            if @comment.try(:id) && can?(:edit, @comment)
                                              comments.item(:edit, I18n.t('general.edit'), edit_comment_path(@comment))
                    Severity: Major
                    Found in lib/voluntary/navigation.rb and 2 other locations - About 45 mins to fix
                    lib/voluntary/navigation.rb on lines 195..200
                    lib/voluntary/navigation.rb on lines 221..226

                    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 3 locations. Consider refactoring.
                    Open

                                    project.item :comments, I18n.t('comments.index.title'), "#{project_path(@project)}#comments" do |comments|
                                      comments.item(:new, I18n.t('general.new'), new_project_comment_path(@project)) if @comment
                                      
                                      if @comment.try(:id) && can?(:edit, @comment)
                                        comments.item(:edit, I18n.t('general.edit'), edit_comment_path(@comment))
                    Severity: Major
                    Found in lib/voluntary/navigation.rb and 2 other locations - About 45 mins to fix
                    lib/voluntary/navigation.rb on lines 195..200
                    lib/voluntary/navigation.rb on lines 206..211

                    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

                    There are no issues that match your filters.

                    Category
                    Status