FanaHOVA/blazer

View on GitHub
app/controllers/concerns/blazer/query_runner.rb

Summary

Maintainability
D
1 day
Test Coverage

Method run_command has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    def run_command(statement)
      @statement = statement
      data_source = params[:data_source]
      process_vars(@statement, data_source)
      @only_chart = params[:only_chart]
Severity: Minor
Found in app/controllers/concerns/blazer/query_runner.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 render_run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def render_run
      @checks = @query ? @query.checks.order(:id) : []

      @first_row = @rows.first || []
      @column_types = []
Severity: Minor
Found in app/controllers/concerns/blazer/query_runner.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 run_command has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run_command(statement)
      @statement = statement
      data_source = params[:data_source]
      process_vars(@statement, data_source)
      @only_chart = params[:only_chart]
Severity: Major
Found in app/controllers/concerns/blazer/query_runner.rb - About 2 hrs to fix

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

        def set_queries(limit = nil)
          @my_queries =
            if limit && blazer_user && !params[:filter] && Blazer.audit
              queries_by_ids(Blazer::Audit.where(user_id: blazer_user.id).where("created_at > ?", 30.days.ago).where("query_id IS NOT NULL").group(:query_id).order("count_all desc").count.keys)
            else
    Severity: Minor
    Found in app/controllers/concerns/blazer/query_runner.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 render_run has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def render_run
          @checks = @query ? @query.checks.order(:id) : []
    
          @first_row = @rows.first || []
          @column_types = []
    Severity: Minor
    Found in app/controllers/concerns/blazer/query_runner.rb - About 1 hr to fix

      Method set_queries has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def set_queries(limit = nil)
            @my_queries =
              if limit && blazer_user && !params[:filter] && Blazer.audit
                queries_by_ids(Blazer::Audit.where(user_id: blazer_user.id).where("created_at > ?", 30.days.ago).where("query_id IS NOT NULL").group(:query_id).order("count_all desc").count.keys)
              else
      Severity: Minor
      Found in app/controllers/concerns/blazer/query_runner.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status