RestPack/restpack_service

View on GitHub

Showing 7 of 7 total issues

Method quote has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def quote(value, column = nil) #:nodoc:
    return super unless column

    sql_type = type_to_sql(column.type, column.limit, column.precision, column.scale)

Severity: Minor
Found in lib/restpack_service/activerecord/postgres_array_patch.rb - About 4 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 type_cast has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def type_cast(value, column, array_member = false)
    return super(value, column) unless column

    case value
    when Range
Severity: Minor
Found in lib/restpack_service/activerecord/postgres_array_patch.rb - About 3 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 quote has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def quote(value, column = nil) #:nodoc:
    return super unless column

    sql_type = type_to_sql(column.type, column.limit, column.precision, column.scale)

Severity: Major
Found in lib/restpack_service/activerecord/postgres_array_patch.rb - About 2 hrs to fix

    Method type_cast has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def type_cast(value, column, array_member = false)
        return super(value, column) unless column
    
        case value
        when Range
    Severity: Minor
    Found in lib/restpack_service/activerecord/postgres_array_patch.rb - About 1 hr to fix

      Method it_acts_as_create_command has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def it_acts_as_create_command
        let(:response) { subject.class.run(params) }
        let(:resource_plural) { subject.Serializer.plural_key }
        let(:resource_singular) { subject.Serializer.singular_key }
      
      
      Severity: Minor
      Found in lib/restpack_service/support/matchers/create_command.rb - About 1 hr to fix

        Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def run
              @response = RestPack::Service::Response.new
        
              begin
                init
        Severity: Minor
        Found in lib/restpack_service/command.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

        Avoid too many return statements within this method.
        Open

              return super(value, column) unless ['inet','cidr'].include? column.sql_type
        Severity: Major
        Found in lib/restpack_service/activerecord/postgres_array_patch.rb - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language