jmuheim/base

View on GitHub

Showing 34 of 34 total issues

Function patch_apply has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    diff_match_patch.prototype.patch_apply = function(a, b) {
        if (0 == a.length) return [b, []];
        a = this.patch_deepCopy(a);
        var c = this.patch_addPadding(a);
        b = c + b + c;
Severity: Minor
Found in app/assets/javascripts/diff_match_patch.js - About 1 hr to fix

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

      def real_input_new
        template.content_tag :div, title: I18n.t('simple_form.inputs.upload.click_to_choose_a_file', attribute: raw_label_text), data: {placement: 'right'} do # We need another div around the whole thing, otherwise Bootstrap tooltip doesn't seem to work! See http://stackoverflow.com/questions/24497353/bootstrap-tooltip-isnt-shown-on-a-specific-element-but-it-seems-to-be-applied
          template.content_tag :a, href: '#', class: ['fileinput-new', 'thumbnail'], data: {trigger: 'fileinput'} do
            if file_available?
              if ['jpg', 'jpeg', 'gif', 'png'].include? object.send(attribute_name).file.extension
    Severity: Minor
    Found in app/inputs/upload_input.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 remove_abandoned_pastables has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def remove_abandoned_pastables
        [:images, :codes].each do |pastables|
          referenced_pastables = []
    
          resource.textareas_accepting_pastables.each do |textarea|
    Severity: Minor
    Found in app/controllers/concerns/pastability_handler.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 navigation_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def navigation_item(*args, &block)
        options = args.extract_options!
    
        if args.size == 2
          title  = args[0]
    Severity: Minor
    Found in app/helpers/navigation_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

    Function diff_bisectSplit_ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        diff_match_patch.prototype.diff_bisectSplit_ = function(a, b, c, d, e) {
    Severity: Minor
    Found in app/assets/javascripts/diff_match_patch.js - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(id, parent_id, options, view, block)
      Severity: Minor
      Found in app/helpers/accordion_helper.rb - About 35 mins to fix

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

          def initialize(options)
            if range = (options.delete(:in) || options.delete(:within))
              raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
              options[:minimum], options[:maximum] = range.begin, range.end
              options[:maximum] -= 1 if range.exclude_end?
        Severity: Minor
        Found in app/validators/file_size_validator.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

              link = link_to '#', class: 'dropdown-toggle', 'data-toggle': 'dropdown', 'aria-expanded': false do
                       group_title += content_tag(:span, " (#{t('layouts.navigation.current_group')})", class: 'sr-only') if has_breadcrumb
                       group_title + content_tag(:b, nil, class: :caret)
        Severity: Minor
        Found in app/helpers/navigation_helper.rb and 1 other location - About 35 mins to fix
        app/helpers/navigation_helper.rb on lines 92..94

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

        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 human_attribute_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.human_attribute_name(attribute_key_name, options = {})
            if respond_to? :translated_attribute_names
              if match = attribute_key_name.match(/^(#{translated_attribute_names.join('|')})_(#{I18n.available_locales.join('|')})$/)
                human_attribute_name = super(match[1], options)
                human_attribute_name += " (#{match[2]})" unless match[2] == I18n.locale.to_s
        Severity: Minor
        Found in app/models/application_record.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

              link = link_to '#', class: 'dropdown-toggle', 'data-toggle': 'dropdown', 'aria-expanded': false do
                       group_title += content_tag(:span, " (#{t('layouts.navigation.current_group')})", class: 'sr-only') if active
                       group_title + content_tag(:b, nil, class: :caret)
        Severity: Minor
        Found in app/helpers/navigation_helper.rb and 1 other location - About 35 mins to fix
        app/helpers/navigation_helper.rb on lines 31..33

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

        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 add_breadcrumbs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_breadcrumbs
            add_breadcrumb Page.model_name.human(count: :other), pages_path if [:index, :new, :create].include? action_name.to_sym
        
            unless action_name == 'index'
              @page.ancestors.reverse.each do |ancestor|
        Severity: Minor
        Found in app/controllers/pages_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 navigation_group has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def navigation_group(group_title, target, item_title = nil, &block)
            group_title = group_title.html_safe
        
            divider = nil
            if item_title.nil?
        Severity: Minor
        Found in app/helpers/navigation_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

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

          def carousel_control_right(id)
            content_tag :a, class: ['right', 'carousel-control'], data: {slide: 'next'}, href: "##{id}", role: 'button' do
              content_tag :span, nil, class: ['fa', 'fa-chevron-right']
            end
        Severity: Minor
        Found in app/helpers/carousel_helper.rb and 1 other location - About 20 mins to fix
        app/helpers/carousel_helper.rb on lines 29..32

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

        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 carousel_control_left(id)
            content_tag :a, class: ['left', 'carousel-control'], data: {slide: 'prev'}, href: "##{id}", role: 'button' do
              content_tag :span, nil, class: ['fa', 'fa-chevron-left']
            end
        Severity: Minor
        Found in app/helpers/carousel_helper.rb and 1 other location - About 20 mins to fix
        app/helpers/carousel_helper.rb on lines 35..38

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

        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

        Severity
        Category
        Status
        Source
        Language