bikeindex/bike_index

View on GitHub

Showing 166 of 166 total issues

Method matching_bulk_imports has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

  def matching_bulk_imports
    return @matching_bulk_imports if defined?(@matching_bulk_imports)
    bulk_imports = BulkImport
    if params[:search_ascend].present?
      bulk_imports = bulk_imports.ascend
Severity: Minor
Found in app/controllers/admin/bulk_imports_controller.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 update has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

  def update
    @user = current_user
    if @user.present? && params[:user].present? && @user.update(permitted_parameters)
      if params.dig(:user, :terms_of_service).present?
        if InputNormalizer.boolean(params.dig(:user, :terms_of_service))
Severity: Minor
Found in app/controllers/users_controller.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 update has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

  def update
    if params[:bike].present?
      begin
        @bike = BikeUpdator.new(user: current_user, bike: @bike, b_params: permitted_bike_params.as_json, current_ownership: @current_ownership).update_available_attributes
      rescue => e
Severity: Minor
Found in app/controllers/bikes_controller.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 update has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

  def update
    error_message = []
    if params[:ownership]
      if params[:ownership][:user_email].present?
        params[:ownership][:user_id] = User.friendly_find_id(params[:ownership].delete(:user_email))
Severity: Minor
Found in app/controllers/admin/ownerships_controller.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 matching_invoices has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

  def matching_invoices
    @query = params[:query]
    invoices = if @query == "active"
      Invoice.active
    elsif @query == "inactive"
Severity: Minor
Found in app/controllers/admin/invoices_controller.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

Function BinxAppOrgBikes has 67 lines of code (exceeds 50 allowed). Consider refactoring.
Open

function BinxAppOrgBikes() {
  return {
    init() {
      // If there aren't search settings on the page, don't do anything
      if ($("#organizedSearchSettings").length) {
Severity: Major
Found in app/javascript/scripts/pages/binx_org_bikes.js - About 1 hr to fix

    Method paint_name_parser has 66 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      def self.paint_name_parser(str)
        paint_str = str.clone.downcase
        paint_str.gsub!(/[\\\/"\-()?,&+;.]/, " ")
    
        # RAL colors. See wikipedia table for rough groupings. Many of the reds are pink, greys are brown, etc. by whatever
    Severity: Major
    Found in app/models/paint.rb - About 1 hr to fix

      Method available_impound_records has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
      Open

          def available_impound_records
            return @available_impound_records if defined?(@available_impound_records)
            if params[:search_status] == "all"
              @search_status = "all"
              a_impound_records = impound_records
      Severity: Minor
      Found in app/controllers/organized/impound_records_controller.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 update has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
      Open

        def update
          @user = current_user
          if params.dig(:user, :password).present?
            unless @user.authenticate(params.dig(:user, :current_password))
              @user.errors.add(:base, translation(:current_password_doesnt_match))
      Severity: Minor
      Found in app/controllers/my_accounts_controller.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 registered_state has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
      Open

              def registered_state(bike = nil)
                state = bike&.status&.gsub("status_", "")
                if state.present?
                  return state if state == "stolen"
                  if %w[abandoned impounded unregistered_parking_notification].include?(state)
      Severity: Minor
      Found in app/controllers/api/v2/bikes.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        enableFields ({ inputFields, selectizedFields }) {
          inputFields.forEach(field => {
            field.element.attr('disabled', false)
            field.label.removeClass('text-muted')
          })
      Severity: Major
      Found in app/javascript/scripts/pages/admin/organization_form.js and 1 other location - About 1 hr to fix
      app/javascript/scripts/pages/admin/organization_form.js on lines 64..74

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 129.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        disableFields ({ inputFields, selectizedFields }) {
          inputFields.forEach(field => {
            field.element.attr('disabled', true)
            field.label.addClass('text-muted')
          })
      Severity: Major
      Found in app/javascript/scripts/pages/admin/organization_form.js and 1 other location - About 1 hr to fix
      app/javascript/scripts/pages/admin/organization_form.js on lines 76..85

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 129.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method authenticate_user has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
      Open

        def authenticate_user(translation_key: nil, translation_args: {}, flash_type: :error)
          translation_key ||= :you_have_to_log_in
      
          # Make absolutely sure the current user is confirmed - mainly for testing
          if current_user&.confirmed?
      Severity: Minor
      Found in app/controllers/concerns/controller_helpers.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 find_sym has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
      Open

          def find_sym(str)
            return if str.blank?
            return str if str.is_a?(Symbol) && self::SLUGS.key?(str)
            str = str.to_s.downcase.strip if str.is_a?(String) || str.is_a?(Symbol)
            if str.is_a?(Integer) || str.match?(/\A\d+\z/)
      Severity: Minor
      Found in app/models/concerns/enumable.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 available_recoveries has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
      Open

        def available_recoveries
          recoveries = StolenRecord.recovered
      
          if params[:search_recovery_display_status] == "all"
            @recovery_display_status = "all"
      Severity: Minor
      Found in app/controllers/admin/recoveries_controller.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 matching_parking_notifications has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
      Open

          def matching_parking_notifications
            return @matching_parking_notifications if defined?(@matching_parking_notifications)
            notifications = parking_notifications
            if params[:search_bike_id].present?
              notifications = notifications.where(bike_id: params[:search_bike_id])
      Severity: Minor
      Found in app/controllers/organized/parking_notifications_controller.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 process_csv has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
      Open

        def process_csv(open_file)
          @line_errors = @bulk_import.line_errors || [] # We always need line_errors
          return false if @bulk_import.finished? # If url fails to load, this will catch
      
          # Grab the first line of the csv (which is the header line) and transform it
      Severity: Minor
      Found in app/workers/bulk_import_worker.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 row_to_b_param_hash has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
      Open

        def row_to_b_param_hash(row_with_whitespaces)
          # remove whitespace from the values in the row
          row = row_with_whitespaces.map { |k, v|
            next [k, v] unless v.is_a?(String)
      
      
      Severity: Minor
      Found in app/workers/bulk_import_worker.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

      Consider simplifying this complex logical expression.
      Open

          if session[:return_to].present? || cookies[:return_to].present? || params[:return_to]
            # NOTE: This is duplicated in permitted_return_to
            target = session[:return_to] || cookies[:return_to] || params[:return_to]
            session[:return_to] = nil
            cookies[:return_to] = nil
      Severity: Critical
      Found in app/controllers/concerns/controller_helpers.rb - About 1 hr to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

              if !@impound_claim.submitting?
                flash[:error] = if @impound_claim.responded?
                  "That claim has already been responded to"
                else
                  "That claim hasn't been submitted yet (it's #{@impound_claim.status_humanized})"
        Severity: Major
        Found in app/controllers/organized/impound_claims_controller.rb and 1 other location - About 1 hr to fix
        app/controllers/review_impound_claims_controller.rb on lines 9..31

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 82.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language