delonnewman/dragnet

View on GitHub

Showing 9 of 227 total issues

Method pull_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def pull_data(answers)
      answers.pull(
        :id,
        :reply_id,
        :survey_id,
Severity: Minor
Found in app/models/dragnet/reply/answer_records.rb - About 1 hr to fix

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

        def method_missing(method_name, *args)
          if method_name.name.end_with?('=')
            raise ArgumentError, "wrong number of arguments expected 1, got #{args.length}" unless args.length == 1
    
            @stash[method_name.name.chop.to_sym] = args.first
    Severity: Minor
    Found in lib/dragnet/command/result.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 fmt_hour has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def fmt_hour(value)
          hour = value.is_a?(Integer) ? value : value.hour
          ampm = hour >= 12 && hour != 24 ? 'PM' : 'AM'
          hr   = hour > 12 ? hour % 12 : hour
          hr   = hr.zero? ? 12 : hr
    Severity: Minor
    Found in lib/dragnet/time_utils.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 define_advising_method has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def define_advising_method(method_name, klass, args = EMPTY_ARRAY, calling: nil, memoize: true)
          define_method(method_name) do |*method_args, **kwargs|
            obj = advising_object_memos.fetch(method_name) do
              klass.new(self, *args).tap do |obj|
                advising_object_memos[method_name] = obj if memoize
    Severity: Minor
    Found in lib/dragnet/advising.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(user:, visit:, tracker:, wants_preview:)
          fail! error: format(SUBMITTED_ERROR, survey.name.inspect) if already_submitted?(visit, wants_preview)
          fail! error: PERMISSION_ERROR unless user.can_create_reply?(survey)
    
          if user.can_preview_survey?(survey, wants_preview: wants_preview)
    Severity: Minor
    Found in app/models/dragnet/survey/dispatch_submission_request.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 button_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def button_to(name = nil, options = nil, html_options = EMPTY_HASH, &block)
        htmx_attr_keys = options.is_a?(Hash) ? HTMX_ONLY_ATTRS & options.keys : EMPTY_ARRAY
        return orig_button_to(name, options, html_options, &block) if htmx_attr_keys.empty?
    
        html_options, options = options, name if block_given?
    Severity: Minor
    Found in app/helpers/htmx_helper.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 survey_open_indicator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def survey_open_indicator(survey)
        htmx = {
          'hx-post'    => survey.open? ? survey_close_path(survey) : survey_open_path(survey),
          'hx-vals'    => { authenticity_token: authenticity_token }.to_json,
          'hx-target'  => "#survey-card-#{survey.id}",
    Severity: Minor
    Found in app/helpers/workspace_helper.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 nav_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def nav_link(content, path = nil, active:, **html_options)
        classes = %w[nav-link]
    
        unless path
          path    = content
    Severity: Minor
    Found in app/helpers/bootstrap5_helper.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 data_grid_display has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def data_grid_display(answers, question, alt: '-')
          return alt if answers.blank?
    
          tag.div(class: 'text-nowrap text-end') do
            answers.map do |answer|
    Severity: Minor
    Found in app/helpers/dragnet/type/time_view.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