ekylibre/active_list

View on GitHub

Showing 48 of 54 total issues

Method columns_to_array has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def columns_to_array(nature, options = {})
        columns = table.exportable_columns

        array = []
        record = options[:record] || 'record_of_the_death'
Severity: Minor
Found in lib/active_list/exporters/abstract_exporter.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 header_code has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def header_code
        code = ''
        code << "'<thead><tr>"
        if table.selectable?
          code << '<th class="list-selector"><input type="checkbox" data-list-selector="all" /></th>'
Severity: Minor
Found in lib/active_list/renderers/simple_renderer.rb - About 1 hr to fix

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

          def exporting_datum_code(record = 'record_of_the_death', noview = false)
            datum = datum_code(record)
            if datatype == :boolean
              datum = "(#{datum} ? ::I18n.translate('list.export.true_value') : ::I18n.translate('list.export.false_value'))"
            elsif datatype == :date
    Severity: Minor
    Found in lib/active_list/definition/data_column.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 controller_method_code has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def controller_method_code
          code = "# encoding: utf-8\n"
          code << "def #{controller_method_name}\n"
          code << session_initialization_code.dig
          code << "  respond_to do |format|\n"
    Severity: Minor
    Found in lib/active_list/generator.rb - About 1 hr to fix

      Method menu_code has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def menu_code
              menu = "<span class=\"list-settings\" data-list-ref=\"#{uid}\">"
              menu << "<a class=\"settings-start\"><i></i>' + h('list.menu'.t) + '</a>"
              menu << '<ul>'
              if table.paginate?
      Severity: Minor
      Found in lib/active_list/renderers/simple_renderer.rb - About 1 hr to fix

        Method conditions_code has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def conditions_code
              conditions = @table.options[:conditions]
              code = ''
              case conditions
              when Array
        Severity: Minor
        Found in lib/active_list/generator/finder.rb - About 1 hr to fix

          Method session_initialization_code has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def session_initialization_code
                code = "options = {} unless options.is_a? Hash\n"
                # For Rails 5
                code << "options.update(params.to_unsafe_h)\n"
                if defined?(User) && User.instance_methods.include?(:preference)
          Severity: Minor
          Found in lib/active_list/generator.rb - About 1 hr to fix

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

                  def add(type, name, options = {})
                    klass = begin
                              "ActiveList::Definition::#{type.to_s.camelcase}Column".constantize
                            rescue
                              nil
            Severity: Minor
            Found in lib/active_list/definition/table.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 session_initialization_code has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def session_initialization_code
                  code = "options = {} unless options.is_a? Hash\n"
                  # For Rails 5
                  code << "options.update(params.to_unsafe_h)\n"
                  if defined?(User) && User.instance_methods.include?(:preference)
            Severity: Minor
            Found in lib/active_list/generator.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

            Avoid deeply nested control flow statements.
            Open

                            currency = :currency if currency.is_a?(TrueClass)
            Severity: Major
            Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              currency = currency[nature] if currency.is_a?(Hash)
              Severity: Major
              Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                column.options[:url] = {} unless column.options[:url].is_a?(Hash)
                Severity: Major
                Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              value_code = (nature == :body ? "text_field_tag(#{form_name.inspect}, #{recordify!(column.options[:value] || column.name, record)}#{column.options[:size] ? ', size: ' + column.options[:size].to_s : ''})" : 'nil') # , id: '#{table.name}_'+#{record}.id.to_s + '_#{column.name}'
                  Severity: Major
                  Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  elsif column.options[:mode] || column.label_method == :email
                                    value_code = "(#{value_code}.blank? ? '' : mail_to(#{value_code}))"
                                  elsif column.options[:mode] || column.label_method == :website
                                    value_code = "(#{value_code}.blank? ? '' : link_to(" + value_code + ', ' + value_code + '))'
                                  elsif column.label_method == :color
                    Severity: Major
                    Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      currency = "#{column.record_expr(record)}.#{currency}".c if currency.is_a?(Symbol)
                      Severity: Major
                      Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if column.form_value
                                        value = recordify(column.form_value, record)
                                      else
                                        value = 1
                                        value_code << "hidden_field_tag(#{form_name.inspect}, 0, id: nil) + \n"
                        Severity: Major
                        Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        elsif column.datatype == :decimal
                                          value_code = "(#{value_code}.nil? ? '' : #{value_code}.l)"
                                        elsif column.enumerize?
                                          value_code = "(#{value_code}.nil? ? '' : #{value_code}.text)"
                          Severity: Major
                          Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      elsif column.is_a?(ActiveList::Definition::ActionColumn)
                                        next unless column.use_single?
                                        value_code = (nature == :body ? column.operation(record) : 'nil')
                                      else
                                        value_code = "'&#160;&#8709;&#160;'.html_safe"
                            Severity: Major
                            Found in lib/active_list/renderers/simple_renderer.rb - About 45 mins to fix

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

                                    def send_data_code
                                      xml_escape = "to_s.gsub('&', '&amp;').gsub('\\'', '&apos;').gsub('<', '&lt;').gsub('>', '&gt;')"
                                      xml_escape << ".force_encoding('US-ASCII')" if xml_escape.respond_to?(:force_encoding)
                                      record = 'r'
                                      code = generator.select_data_code(paginate: false)
                              Severity: Minor
                              Found in lib/active_list/exporters/open_document_spreadsheet_exporter.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 reflections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def reflections
                                      hash = []
                                      columns.each do |column|
                                        next unless column.respond_to?(:reflection)
                                        unless hash.detect { |r| r.name == column.reflection.name }
                              Severity: Minor
                              Found in lib/active_list/definition/table.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

                              Severity
                              Category
                              Status
                              Source
                              Language