resource-watch/prep-api

View on GitHub

Showing 12 of 25 total issues

Method index has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    dashboards =
      if params[:env].present?
        environments = params[:env].split(',')

Severity: Minor
Found in app/controllers/api/dashboards_controller.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 index has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def index
    dashboards =
      if params[:env].present?
        environments = params[:env].split(',')

Severity: Minor
Found in app/controllers/api/dashboards_controller.rb - About 1 hr to fix

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

      def manage_content(base_url)
        content_images.each(&:destroy)
        contents = JSON.parse(content)
    
        contents.each do |content_block|
    Severity: Minor
    Found in app/models/dashboard.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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        partners =
          if params[:env].present?
            environments = params[:env].split(',')
    
    
    Severity: Minor
    Found in app/controllers/api/partners_controller.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 assign_content_image_url has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def assign_content_image_url(contents, content, base_url, is_grid = false, grid = nil)
    Severity: Minor
    Found in app/models/dashboard.rb - About 35 mins to fix

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

        def index
          core_datasets =
            if params[:env].present?
              environments = params[:env].split(',')
      
      
      Severity: Minor
      Found in app/controllers/api/core_datasets_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

      Method set_dashboard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_dashboard
          environments = params[:env].present? ? params[:env].split(',') : ['production']
          dashboard = params[:id].id? ? Dashboard.find_by(id: params[:id]) : Dashboard.find_by(slug: params[:id])
      
          matches = environments.map do |env|
      Severity: Minor
      Found in app/controllers/api/dashboards_controller.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 set_resource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_resource
          environments = params[:env].present? ? params[:env].split(',') : ['production']
          resource = params[:id].id? ? Resource.find_by(id: params[:id]) : Resource.find_by(slug: params[:id])
      
          matches = environments.map do |env|
      Severity: Minor
      Found in app/controllers/api/resources_controller.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 set_insight has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_insight
          environments = params[:env].present? ? params[:env].split(',') : ['production']
          insight = params[:id].id? ? Insight.find_by(id: params[:id]) : Insight.find_by(slug: params[:id])
      
          matches = environments.map do |env|
      Severity: Minor
      Found in app/controllers/api/insights_controller.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          insights =
            if params[:env].present?
              environments = params[:env].split(',')
      
      
      Severity: Minor
      Found in app/controllers/api/insights_controller.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 set_core_dataset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_core_dataset
            environments = params[:env].present? ? params[:env].split(',') : ['production']
            core_dataset = params[:id].id? ? CoreDataset.find_by(id: params[:id]) : CoreDataset.find_by(slug: params[:id])
      
            matches = environments.map do |env|
      Severity: Minor
      Found in app/controllers/api/core_datasets_controller.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          tools =
            if params[:env].present?
              environments = params[:env].split(',')
      
      
      Severity: Minor
      Found in app/controllers/api/tools_controller.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

      Severity
      Category
      Status
      Source
      Language