ashrafuzzaman/query_report

View on GitHub

Showing 7 of 7 total issues

Method column_total_with_colspan has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def column_total_with_colspan
        total_with_colspan = []
        colspan = 0
        total_text_printed = false
        columns.each do |column|
Severity: Minor
Found in lib/query_report/column_module/dsl.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 generate_comparators has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def generate_comparators
        @options[:comp] ||= case @type
                              when :date
                                {gteq: I18n.t('query_report.filters.from'), lteq: I18n.t('query_report.filters.to')}
                              when :datetime
Severity: Minor
Found in lib/query_report/filter_module/filter.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 map_rowspan has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def map_rowspan(recs)
      return recs unless has_any_rowspan?

      last_reset_index = @columns.select(&:rowspan?).inject({}) { |hash, column| hash[column.humanize] = 0; hash }
      rowspan_column_hash = @columns.select(&:rowspan?).inject({}) { |hash, column| hash[column.humanize] = column.rowspan_column_humanized; hash }
Severity: Minor
Found in lib/query_report/record.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 send_report has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def send_report(user, to, subject, message, file_name, attachment)
Severity: Minor
Found in app/mailers/report_mailer.rb - About 45 mins to fix

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

        def generate_csv_for_report(records)
          if records.size > 0
            columns = records.first.keys
            CSV.generate do |csv|
              csv << columns
    Severity: Minor
    Found in lib/query_report/helper.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 send_pdf_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def send_pdf_email(email, subject, message, file_name, attachment)
    Severity: Minor
    Found in lib/query_report/helper.rb - About 35 mins to fix

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

            def initialize(report, column_name, options={}, block = nil)
              @report, @name, @options = report, column_name, options
              if @report.model_class
                @type = @report.model_class.columns_hash[column_name.to_s].try(:type) || options[:type] || :string rescue :string
              else
      Severity: Minor
      Found in lib/query_report/column_module/column.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