bikeindex/bike_index

View on GitHub

Showing 166 of 166 total issues

Class Bike has 90 methods (exceeds 40 allowed). Consider refactoring.
Open

class Bike < ApplicationRecord
  include ActiveModel::Dirty
  include BikeSearchable
  include BikeAttributable
  include Geocodeable
Severity: Major
Found in app/models/bike.rb - About 1 day to fix

    Class Organization has 85 methods (exceeds 40 allowed). Consider refactoring.
    Open

    class Organization < ApplicationRecord
      include ActionView::Helpers::SanitizeHelper
      include SearchRadiusMetricable
    
      KIND_ENUM = {
    Severity: Major
    Found in app/models/organization.rb - About 1 day to fix

      Method countries has 245 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

        def countries
          [
            {name: "Afghanistan", iso: "AF"},
            {name: "Albania", iso: "AL"},
            {name: "Algeria", iso: "DZ"},
      Severity: Major
      Found in app/models/states_and_countries.rb - About 1 day to fix

        Class BParam has 74 methods (exceeds 40 allowed). Consider refactoring.
        Open

        class BParam < ApplicationRecord
          mount_uploader :image, ImageUploader
          store_in_background :image, CarrierWaveStoreWorker
        
          # serialize :params
        Severity: Major
        Found in app/models/b_param.rb - About 7 hrs to fix

          Class User has 69 methods (exceeds 40 allowed). Consider refactoring.
          Open

          class User < ApplicationRecord
            include ActionView::Helpers::SanitizeHelper
            include FeatureFlaggable
            include Geocodeable
          
          
          Severity: Major
          Found in app/models/user.rb - About 6 hrs to fix

            File bike.rb has 674 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            class Bike < ApplicationRecord
              include ActiveModel::Dirty
              include BikeSearchable
              include BikeAttributable
              include Geocodeable
            Severity: Major
            Found in app/models/bike.rb - About 6 hrs to fix

              Function BinxAdmin has 151 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              function BinxAdmin () {
                return {
                  init () {
                    this.initAdminSearchSelect()
                    this.initBikeTabs()
              Severity: Major
              Found in app/javascript/scripts/pages/admin/binx_admin.js - About 5 hrs to fix

                Class GraduatedNotification has 57 methods (exceeds 40 allowed). Consider refactoring.
                Open

                class GraduatedNotification < ApplicationRecord
                  STATUS_ENUM = {pending: 0, bike_graduated: 1, marked_remaining: 2}.freeze
                  PENDING_PERIOD = 24.hours.freeze
                
                  belongs_to :bike
                Severity: Major
                Found in app/models/graduated_notification.rb - About 4 hrs to fix

                  Method create has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring.
                  Open

                    def create
                      find_or_new_b_param
                      org_param = (@b_param.organization || current_organization)&.slug # Protect from nil - see #2308
                      if params.dig(:bike, :embeded).present? && org_param.present? # NOTE: if embeded, doesn't verify csrf token
                        if @b_param.created_bike.present?
                  Severity: Minor
                  Found in app/controllers/bikes_controller.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

                  Function BinxAdmin has a Cognitive Complexity of 31 (exceeds 10 allowed). Consider refactoring.
                  Open

                  function BinxAdmin () {
                    return {
                      init () {
                        this.initAdminSearchSelect()
                        this.initBikeTabs()
                  Severity: Minor
                  Found in app/javascript/scripts/pages/admin/binx_admin.js - 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 user_icon has a Cognitive Complexity of 30 (exceeds 10 allowed). Consider refactoring.
                  Open

                    def user_icon(user = nil, full_text: false)
                      icon_hash = user_icon_hash(user)
                      return "" if icon_hash[:tags].empty?
                      # TODO: return individual tags, so you can show them e.g. for organizations
                      content_tag :span do
                  Severity: Minor
                  Found in app/helpers/admin_helper.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 parse has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring.
                  Open

                    def self.parse(time_str = nil, timezone_str = nil)
                      return nil unless time_str.present?
                      return time_str if time_str.is_a?(Time)
                      if time_str.is_a?(Integer) || time_str.is_a?(Float) || time_str.to_s.strip.match(/^\d+\z/) # it's only numbers
                        return parse("#{time_str}-01-01") if time_str.to_s.length == 4 # Looks a year, valid 8601 format
                  Severity: Minor
                  Found in app/services/time_parser.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

                  Class ParkingNotification has 46 methods (exceeds 40 allowed). Consider refactoring.
                  Open

                  class ParkingNotification < ActiveRecord::Base
                    include Geocodeable
                    KIND_ENUM = {appears_abandoned_notification: 0, parked_incorrectly_notification: 1, impound_notification: 2}.freeze
                    STATUS_ENUM = {current: 0, replaced: 1, impounded: 2, retrieved: 3, impounded_retrieved: 5, resolved_otherwise: 4}.freeze
                    RETRIEVED_KIND_ENUM = {organization_recovery: 0, link_token_recovery: 1, user_recovery: 2}.freeze
                  Severity: Minor
                  Found in app/models/parking_notification.rb - About 3 hrs to fix

                    Class TheftAlert has 45 methods (exceeds 40 allowed). Consider refactoring.
                    Open

                    class TheftAlert < ApplicationRecord
                      STATUS_ENUM = {pending: 0, active: 1, inactive: 2}.freeze
                      # Timestamp 1s before first alert was automated
                      AUTOMATION_START = 1625586988 # 2021-7-6
                    
                    
                    Severity: Minor
                    Found in app/models/theft_alert.rb - About 2 hrs to fix

                      Function PeriodSelector has 95 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      function PeriodSelector() {
                        return {
                          init() {
                            this.autoSubmit = !(
                              $("#timeSelectionBtnGroup").attr("data-nosubmit") == "true"
                      Severity: Major
                      Found in app/javascript/scripts/utils/period_selector.js - About 2 hrs to fix

                        Method matching_bikes has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
                        Open

                          def matching_bikes
                            if params[:user_id].present?
                              @user = User.username_friendly_find(params[:user_id])
                              bikes = @user.bikes
                            elsif params[:search_phone].present?
                        Severity: Minor
                        Found in app/controllers/admin/bikes_controller.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 set_calculated_attributes has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
                        Open

                          def set_calculated_attributes
                            # Gotta assign this before checking email, in case it's a phone reg
                            self.is_phone ||= bike.phone_registration? if id.blank? && bike.present?
                            self.owner_email ||= bike&.owner_email
                            self.owner_email = EmailNormalizer.normalize(owner_email)
                        Severity: Minor
                        Found in app/models/ownership.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 vowel_frequency_suspiciousness has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
                        Open

                            def vowel_frequency_suspiciousness(str, str_length = nil, str_downlate = nil)
                              str_length ||= str.length.to_f
                              return 0 if str_length < 4 # 3 letters or less get a pass
                        
                              vowel_percent = vowel_ratio(str, str_length) * 100
                        Severity: Minor
                        Found in app/services/spam_estimator.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

                        Function MultiSerialSearch has 90 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        const MultiSerialSearch = () => {
                          const [serialResults, setSerialResults] = useState(null)
                          const [searchTokens, setSearchTokens] = useState('')
                          const [loading, setLoading] = useState(false)
                          const [fuzzySearching, setFuzzySearching] = useState(false)
                        Severity: Major
                        Found in app/javascript/scripts/multi_serial_search/MultiSerialSearch.jsx - About 2 hrs to fix

                          Method send_request has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
                          Open

                                def send_request
                                  bike_id = params[:request_bike_id]
                                  reason = params[:request_reason]
                                  feedback_type = params[:request_type]
                                  if current_user.present? && reason.present? && bike_id.present? && feedback_type.present?
                          Severity: Minor
                          Found in app/controllers/api/v1/users_controller.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

                          Severity
                          Category
                          Status
                          Source
                          Language