TrestleAdmin/trestle

View on GitHub

Showing 54 of 69 total issues

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

        def initialize(builder, template, name=nil, options={}, &block)
Severity: Minor
Found in lib/trestle/form/fields/form_group.rb - About 35 mins to fix

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

      def initialize(builder, template, name, options={}, &block)
    Severity: Minor
    Found in sandbox/app/fields/custom_field.rb - About 35 mins to fix

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

            def initialize(builder, template, name, options={}, &block)
      Severity: Minor
      Found in lib/trestle/form/field.rb - About 35 mins to fix

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

            def col(columns=nil, breakpoints={})
              if columns.is_a?(Hash)
                breakpoints = columns
                columns = breakpoints.delete("xs") || breakpoints.delete(:xs)
              end
        Severity: Minor
        Found in app/helpers/trestle/grid_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 redirect_to_return_location has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def redirect_to_return_location(action, instance, status: :found, default: nil, &block)
                  fallback_location = block_given? ? block : default
        
                  if admin.return_locations[action] && !modal_request?
                    location = instance_exec(instance, &admin.return_locations[action])
        Severity: Minor
        Found in app/controllers/concerns/trestle/resource/controller/redirection.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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def fetch(name)
              name = name.to_sym
        
              options.fetch(name) {
                if defaults.key?(name)
        Severity: Minor
        Found in lib/trestle/configurable.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 hue_to_rgb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.hue_to_rgb(p, q, t)
              t += 1 if t < 0
              t -= 1 if t > 1
        
              if t < 1 / 6.0
        Severity: Minor
        Found in lib/trestle/color.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 merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def merge!(other, &block)
              super(other || {}) do |key, v1, v2|
                if v1.is_a?(Hash) && v2.is_a?(Hash)
                  v1.merge(v2, &block)
                elsif v1.is_a?(Array)
        Severity: Minor
        Found in lib/trestle/options.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

        Function _rgbToHsl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          _rgbToHsl (r, g, b) {
            r /= 255
            g /= 255
            b /= 255
        
        

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

          follow (e) {
            if (this.ignoreElement(e.target) || !this.url) {
              return
            }
        
        
        Severity: Minor
        Found in frontend/js/controllers/follow_url_controller.js - 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 apply_sorting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def apply_sorting(collection, params)
                return collection unless params[:sort]
        
                field = params[:sort].to_sym
                order = params[:order].to_s.downcase == "desc" ? :desc : :asc
        Severity: Minor
        Found in lib/trestle/resource/collection.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 header_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def header_text
                  if header = options[:header]
                    if header.respond_to?(:call)
                      @template.instance_exec(&header)
                    else
        Severity: Minor
        Found in lib/trestle/table/column.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 batch_post
              ids = params[:ids].split(",")
              flash[:message] = { title: "Success!", message: "Performed batch action via POST with #{ids.size} articles." }
              redirect_back fallback_location: admin.path
            end
        Severity: Minor
        Found in sandbox/app/admin/articles_admin.rb and 1 other location - About 15 mins to fix
        sandbox/app/admin/articles_admin.rb on lines 73..77

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

        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 batch_get
              ids = params[:ids].split(",")
              flash[:message] = { title: "Success!", message: "Performed batch action via GET with #{ids.size} articles." }
              redirect_back fallback_location: admin.path
            end
        Severity: Minor
        Found in sandbox/app/admin/articles_admin.rb and 1 other location - About 15 mins to fix
        sandbox/app/admin/articles_admin.rb on lines 79..83

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

        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