gooddata/gooddata-ruby

View on GitHub
bin/test_projects_cleanup.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method delete_segment_by_title has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def delete_segment_by_title(title, segments, days = 14, force = false)
  return if segments.empty?
  dead_line = Time.now - days * 60 * 60 * 24

  filtered_segments = segments.select do |s|
Severity: Minor
Found in bin/test_projects_cleanup.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 delete_ads_by_title has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def delete_ads_by_title(title, client, days = 14, force = false)
  warehouses = client.warehouses
  return if warehouses.empty?

  deleted = 0
Severity: Minor
Found in bin/test_projects_cleanup.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 clean_up! has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def clean_up!(client, force, days, opts = {})
  projects = client.projects

  if opts[:domain_id]
    domain = client.domain(opts[:domain_id])
Severity: Minor
Found in bin/test_projects_cleanup.rb - About 1 hr to fix

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

    def delete_project_by_title(title, projects, days = 14, force = false)
      dead_line = Time.now - days * 60 * 60 * 24
      filtered_projects = projects.select do |p|
        p.title.match(title) && p.created < dead_line
      end
    Severity: Minor
    Found in bin/test_projects_cleanup.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

    There are no issues that match your filters.

    Category
    Status