bikeindex/bike_index

View on GitHub

Showing 167 of 167 total issues

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/review_impound_claims_controller.rb and 1 other location - About 1 hr to fix
app/controllers/organized/impound_claims_controller.rb on lines 20..42

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

Function BinxAdminBlogs has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

function BinxAdminBlogs() {
  return {
    init() {
      this.initializeBlogInfoToggling();
      this.initializePrimaryPhotoFunctionality();
Severity: Major
Found in app/javascript/scripts/pages/admin/blogs.js - About 1 hr to fix

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

      def create
        @feedback = Feedback.new(permitted_parameters)
        @feedback.user_id = current_user.id if current_user.present?
        return true if block_the_spam(@feedback)
    
    
    Severity: Minor
    Found in app/controllers/feedbacks_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 missing_manufacturer_bikes has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

      def missing_manufacturer_bikes
        session.delete(:missing_manufacturer_time_order) if params[:reset_view].present?
        if params[:search_time_ordered].present?
          session[:missing_manufacturer_time_order] = InputNormalizer.boolean(params[:search_time_ordered])
        end
    Severity: Minor
    Found in app/controllers/admin/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 16 (exceeds 10 allowed). Consider refactoring.
    Open

      def update
        if params[:force_merge_email].present?
          force_merge_users(params[:force_merge_email])
        else
          @user.name = params[:user][:name]
    Severity: Minor
    Found in app/controllers/admin/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 16 (exceeds 10 allowed). Consider refactoring.
    Open

          def update
            @organization = Organization.friendly_find(params[:id])
            if @organization.blank?
              redirect_to(api_v1_not_found_url) && return
            elsif params[:access_token] == @organization.access_token
    Severity: Minor
    Found in app/controllers/api/v1/organizations_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 calculated_pos_kind has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

      def self.calculated_pos_kind(organization)
        return organization.manual_pos_kind if organization.manual_pos_kind.present?
        bikes = organization.created_bikes # NOTE: Only created, so regional orgs don't get them
        recent_bikes = bikes.where(created_at: (Time.current - 1.week)..Time.current)
        if organization.ascend_name.present? || recent_bikes.ascend_pos.count > 0
    Severity: Minor
    Found in app/workers/update_organization_pos_kind_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

    Function localizedDateText has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

      localizedDateText (
        time,
        singleFormat,
        preciseTime,
        includeSeconds,
    Severity: Minor
    Found in app/javascript/scripts/utils/time_parser.js - 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 16 (exceeds 10 allowed). Consider refactoring.
    Open

        def update
          if !@impound_claim.submitting?
            flash[:error] = if @impound_claim.responded?
              "That claim has already been responded to"
            else
    Severity: Minor
    Found in app/controllers/organized/impound_claims_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 16 (exceeds 10 allowed). Consider refactoring.
    Open

      def update
        if !@impound_claim.submitting?
          flash[:error] = if @impound_claim.responded?
            "That claim has already been responded to"
          else
    Severity: Minor
    Found in app/controllers/review_impound_claims_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 init has 56 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

        init () {
          this.initAdminSearchSelect()
          this.initBikeTabs()
    
          // Enable utilities
    Severity: Major
    Found in app/javascript/scripts/pages/admin/binx_admin.js - About 1 hr to fix

      Method states has 54 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

        def states
          [
            {name: "Alabama", abbr: "AL"},
            {name: "Alaska", abbr: "AK"},
            {name: "Arizona", abbr: "AZ"},
      Severity: Major
      Found in app/models/states_and_countries.rb - About 1 hr to fix

        Method parse has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
        Open

          def self.parse(payload, sso_secret = nil)
            sso = new
            sso.sso_secret = sso_secret if sso_secret
        
            parsed = Rack::Utils.parse_query(payload)
        Severity: Minor
        Found in app/models/single_sign_on.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 set_period has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
        Open

          def set_period
            @timezone ||= Time.zone
            # Set time period
            @period ||= params[:period]
            if @period == "custom"
        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 matching_user_alerts has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
        Open

          def matching_user_alerts
            user_alerts = UserAlert
            if UserAlert.kinds.include?(params[:search_kind])
              @kind = params[:search_kind]
              user_alerts = user_alerts.where(kind: @kind)
        Severity: Minor
        Found in app/controllers/admin/user_alerts_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 perform has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
        Open

          def perform(bike_id)
            bike = Bike.unscoped.where(id: bike_id).first
            if bike.present?
              bb_data = BikeBookIntegration.new.get_model(bike)
        
        
        Severity: Minor
        Found in app/workers/bike_book_update_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

        Function exports has 51 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        module.exports = function (api) {
          var validEnv = ['development', 'test', 'production']
          var currentEnv = api.env()
          var isDevelopmentEnv = api.env('development')
          var isProductionEnv = api.env('production')
        Severity: Major
        Found in babel.config.js - About 1 hr to fix

          Method set_location_info has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
          Open

            def set_location_info
              if current_stolen_record.present?
                # If there is a current stolen - even if it has a blank location - use it
                # It's used for searching and displaying stolen bikes, we don't want other information leaking
                self.attributes = if address_set_manually # Only set coordinates if the address is set manually
          Severity: Minor
          Found in app/models/bike.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 build_bike_status has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
          Open

            def build_bike_status
              self.max_char = compute_max_char
          
              location = ""
              if !close_twitter_accounts&.first&.default? && neighborhood.present?
          Severity: Minor
          Found in app/integrations/twitter_tweeter_integration.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 available_graduated_notifications has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
          Open

              def available_graduated_notifications
                return @available_graduated_notifications if defined?(@available_graduated_notifications)
                if params[:search_status] == "all"
                  @search_status = "all"
                  a_graduated_notifications = graduated_notifications
          Severity: Minor
          Found in app/controllers/organized/graduated_notifications_controller.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

          Severity
          Category
          Status
          Source
          Language