NYULibraries/gather_content-api

View on GitHub

Showing 5 of 12 total issues

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

      def parse_message(response)
        parsed = JSON.parse(response.body)

        return response.body unless parsed.is_a?(Hash)
        return parsed['data'].join(' ') if parsed['data'].is_a?(Array)
Severity: Minor
Found in lib/gather_content/error/request_error.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 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(name = "", required = false, label = "", microcopy = "", value = "", limit_type = :chars, limit = 0, plain_text = true)
Severity: Major
Found in lib/gather_content/config/elements/text.rb - About 1 hr to fix

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

          def create(data)
            data.delete("parent_id") if data["parent_id"].nil? || data["parent_id"].empty?
            data.delete("template_id") if data["template_id"].nil? || data["template_id"].empty?
    
            config = data.delete("config")
    Severity: Minor
    Found in lib/gather_content/api/items.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def create(data)
            data.delete("type") if data["type"].nil? || data["type"].empty?
    
            raise ArgumentError, "name is required!" if data["name"].nil? || data["name"].empty?
            raise ArgumentError, "type is invalid!" unless valid_type?(data["type"])
    Severity: Minor
    Found in lib/gather_content/api/projects.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

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

            def initialize(name = "", required = false, label = "", microcopy = "", other_option = false)
    Severity: Minor
    Found in lib/gather_content/config/elements/choice_radio.rb - About 35 mins to fix
      Severity
      Category
      Status
      Source
      Language