platehub/plate_api

View on GitHub

Showing 13 of 13 total issues

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

    def index_block(parent_class, parent_id, extra_params = {}, &block)
      extra_params[:page] = extra_params.delete("page") if extra_params["page"]
      extra_params[:page] = 1 unless extra_params[:page]

      pagination = index_block_iteration(parent_class, parent_id, extra_params, &block)
Severity: Minor
Found in lib/plate_api/object_handler.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(public_key, secret, path, parameters={}, custom_server=nil)
Severity: Minor
Found in lib/plate_api/delete_request.rb - About 35 mins to fix

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

        def initialize(public_key, secret, method, path, custom_server = nil)
    Severity: Minor
    Found in lib/plate_api/request.rb - About 35 mins to fix

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

          def initialize(public_key, secret, path, parameters = {}, custom_server = nil)
      Severity: Minor
      Found in lib/plate_api/post_multipart_request.rb - About 35 mins to fix

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

            def initialize(public_key, secret, path, parameters={}, custom_server=nil)
        Severity: Minor
        Found in lib/plate_api/post_request.rb - About 35 mins to fix

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

              def initialize(public_key, secret, path, parameters={}, custom_server=nil)
          Severity: Minor
          Found in lib/plate_api/get_request.rb - About 35 mins to fix

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

                def initialize(public_key, secret, path, parameters={}, custom_server=nil)
            Severity: Minor
            Found in lib/plate_api/put_request.rb - About 35 mins to fix

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

                  def create(parent, attributes, create_method = :post)
                    raise ArgumentError, "`parent` given for #create is not valid" unless parent
                    raise ArgumentError, "`attributes` given for #create is not valid" unless attributes.is_a?(Hash)
              
                    parameters = case create_method
              Severity: Minor
              Found in lib/plate_api/object_handler.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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def index(parent_class, parent_id, extra_params = {}, return_raw = false)
                    raise ArgumentError, "`parent_id` given for #index is not valid" unless parent_id
                    raise ArgumentError, "`parent_class` given for #index is not valid" unless parent_class
              
                    result = @api_connector.get(collection_path(parent_class, parent_id), extra_params)
              Severity: Minor
              Found in lib/plate_api/object_handler.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update(attributes)
                    raise ArgumentError, "Input `attributes` is not a Hash" unless attributes.is_a?(Hash)
                    raise ArgumentError, "No object_handler is attached to this object" unless @object_handler
              
                    if new_object = @object_handler.update(@id, attributes)
              Severity: Minor
              Found in lib/plate_api/plate_object/base.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def update(id, attributes)
                    raise ArgumentError, "`id` given for #update is not valid" unless id
                    raise ArgumentError, "`attributes` given for #update is not valid" unless attributes.is_a?(Hash)
              
                    result = @api_connector.put(resource_path(id), { "data" => attributes })
              Severity: Minor
              Found in lib/plate_api/object_handler.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

                class PutRequest < Request
              
                  def initialize(public_key, secret, path, parameters={}, custom_server=nil)
                    super(public_key, secret, "PUT", path, custom_server)
              
              
              Severity: Minor
              Found in lib/plate_api/put_request.rb and 1 other location - About 20 mins to fix
              lib/plate_api/post_request.rb on lines 4..14

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

              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

                class PostRequest < Request
              
                  def initialize(public_key, secret, path, parameters={}, custom_server=nil)
                    super(public_key, secret, "POST", path, custom_server)
              
              
              Severity: Minor
              Found in lib/plate_api/post_request.rb and 1 other location - About 20 mins to fix
              lib/plate_api/put_request.rb on lines 2..12

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

              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