frc-frecon/frecon

View on GitHub
lib/frecon/controller.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method create has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

        def self.create(request, params, post_data = nil)
            post_data ||= process_json_request request

            if post_data.is_an? Array
                results = post_data.map do |post_data_item|
Severity: Minor
Found in lib/frecon/controller.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 create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def self.create(request, params, post_data = nil)
            post_data ||= process_json_request request

            if post_data.is_an? Array
                results = post_data.map do |post_data_item|
Severity: Minor
Found in lib/frecon/controller.rb - About 1 hr to fix

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

            def self.update(request, params, post_data = nil)
                raise RequestError.new(400, "Must supply a #{model_name.downcase} id!") unless params[:id]
    
                post_data ||= process_json_request request
    
    
    Severity: Minor
    Found in lib/frecon/controller.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

    Shadowing outer local variable - status_code.
    Open

                       end.select do |status_code|
    Severity: Minor
    Found in lib/frecon/controller.rb by rubocop

    This cop looks for use of the same name as outer local variables for block arguments or block local variables. This is a mimic of the warning "shadowing outer local variable - foo" from ruby -cw.

    Example:

    # bad
    
    def some_method
      foo = 1
    
      2.times do |foo| # shadowing outer `foo`
        do_something(foo)
      end
    end

    Example:

    # good
    
    def some_method
      foo = 1
    
      2.times do |bar|
        do_something(bar)
      end
    end

    There are no issues that match your filters.

    Category
    Status