concord-consortium/rigse

View on GitHub
rails/app/helpers/application_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

File application_helper.rb has 485 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ApplicationHelper
  include Clipboard
  include Pundit

  def current_settings
Severity: Minor
Found in rails/app/helpers/application_helper.rb - About 7 hrs to fix

    Method for_teacher_only? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def for_teacher_only?(thing)
        if (thing.respond_to?("teacher_only?") && thing.teacher_only?)
          return true;
        end
        if thing.respond_to? :parent
    Severity: Minor
    Found in rails/app/helpers/application_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 accordion_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def accordion_for(model, title, dom_prefix='', options={})
        show_hide_text = options[:show_hide_text]
        capture_haml do
          haml_tag :div, :id => dom_id_for(model, dom_prefix), :class => 'accordion_container' do
            haml_tag :div, :class => 'accordion_name' do
    Severity: Minor
    Found in rails/app/helpers/application_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 login_line has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def login_line(options = {})
        opts = {
          :welcome  => "Welcome",
          :login => "Login",
          :signup => "Sign up",
    Severity: Minor
    Found in rails/app/helpers/application_helper.rb - About 1 hr to fix

      Method accordion_for has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def accordion_for(model, title, dom_prefix='', options={})
          show_hide_text = options[:show_hide_text]
          capture_haml do
            haml_tag :div, :id => dom_id_for(model, dom_prefix), :class => 'accordion_container' do
              haml_tag :div, :class => 'accordion_name' do
      Severity: Minor
      Found in rails/app/helpers/application_helper.rb - About 1 hr to fix

        Method name_for_component has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def name_for_component(component, options={})
            if options[:display_name]
              return options[:display_name]
            end
            name = ''
        Severity: Minor
        Found in rails/app/helpers/application_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 in_render_scope? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def in_render_scope?(thing)
            return true if thing == nil
            if already_rendered?(thing)
              return true
            end
        Severity: Minor
        Found in rails/app/helpers/application_helper.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 edit_menu_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def edit_menu_for(component, form, options={:omit_cancel => true}, scope=false)
            component = (component.respond_to? :embeddable) ? component.embeddable : component
            capture_haml do
              haml_tag :div, :class => 'action_menu' do
                haml_tag :div, :class => 'action_menu_header_left' do
        Severity: Minor
        Found in rails/app/helpers/application_helper.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 students_in_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def students_in_class(all_students)
            all_students.to_a.compact.uniq.sort{|a,b| (a.user ? [a.first_name, a.last_name] : ["",""]) <=> (b.user ? [b.first_name, b.last_name] : ["",""])}
          end
        Severity: Minor
        Found in rails/app/helpers/application_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 class_link_for_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def class_link_for_user
            if current_visitor.portal_teacher
              if current_visitor.has_active_classes?
                recent_activity_path
              else
        Severity: Minor
        Found in rails/app/helpers/application_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 login_line has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def login_line(options = {})
            opts = {
              :welcome  => "Welcome",
              :login => "Login",
              :signup => "Sign up",
        Severity: Minor
        Found in rails/app/helpers/application_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 current_user_home_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def current_user_home_path
            if current_user.nil?
              # anonymous home is the '/'
              root_path
            elsif BoolENV['RESEARCHER_REPORT_ONLY']
        Severity: Minor
        Found in rails/app/helpers/application_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

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

          def students_in_class(all_students)
            all_students.to_a.compact.uniq.sort{|a,b| (a.user ? [a.first_name, a.last_name] : ["",""]) <=> (b.user ? [b.first_name, b.last_name] : ["",""])}
        Severity: Minor
        Found in rails/app/helpers/application_helper.rb and 1 other location - About 30 mins to fix
        rails/app/helpers/portal/student_clazzes_helper.rb on lines 3..4

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

        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