gitcoinco/code_fund_ads

View on GitHub

Showing 211 of 211 total issues

Function quill has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  quill () {
    if (window.Quill) {
      $('[data-toggle="quill"]').each(function () {
        const selector = this
        const options = $(selector).data()
Severity: Minor
Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

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

        def data
          @data ||= begin
            # TODO: update the multiplier strategy after all campaigns with a start_date before 2019-03-07 have completed
            subregion_cpm_multipliers = YAML.safe_load(File.read(Rails.root.join("config/subregion_cpm_multipliers.yml")))
            country_cpm_multipliers = YAML.safe_load(File.read(Rails.root.join("config/country_cpm_multipliers.yml")))
    Severity: Minor
    Found in app/models/province.rb - About 1 hr to fix

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

            xaxis: {
              tickColor: isDarkSkin
                ? this.hexToRgba(colors.white, 0.08)
                : this.hexToRgba(colors.black, 0.1),
              color: isDarkSkin ? gray[400] : gray[600]
      Severity: Major
      Found in app/javascript/themes/current/components/theme.js and 1 other location - About 1 hr to fix
      app/javascript/themes/current/components/theme.js on lines 1006..1011

      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 62.

      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

            yaxis: {
              tickColor: isDarkSkin
                ? this.hexToRgba(colors.white, 0.08)
                : this.hexToRgba(colors.black, 0.1),
              color: isDarkSkin ? gray[400] : gray[600]
      Severity: Major
      Found in app/javascript/themes/current/components/theme.js and 1 other location - About 1 hr to fix
      app/javascript/themes/current/components/theme.js on lines 1000..1005

      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 62.

      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 flatpickr has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        flatpickr () {
          if (window.flatpickr) {
            flatpickr.defaultConfig.disableMobile = true
      
            $('[data-toggle="flatpickr"]').each(function () {
      Severity: Minor
      Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

        Method perform has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def perform(campaign_id, property_id, ip_address, user_agent, clicked_at_string)
            ScoutApm::Transaction.ignore! if rand > (ENV["SCOUT_SAMPLE_RATE"] || 1).to_f
            campaign = Campaign.find_by(id: campaign_id)
            return unless campaign&.sponsor?
        
        
        Severity: Minor
        Found in app/jobs/create_impression_and_click_job.rb - About 1 hr to fix

          Function constructor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor () {
              // looper color scheme refer from our _variable-bs-overrides.scss
              this.colors = {
                black: '#14141F',
                brand: {
          Severity: Minor
          Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

            Function zxcvbn has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              zxcvbn () {
                if (window.zxcvbn) {
                  $('.form-strength-meter').each(function () {
                    const input = this
                    const indicator = $(this).data('indicator')
            Severity: Minor
            Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

              Method render_pricing_table has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def render_pricing_table
                  @base = Money.new((params[:base] || ENV.fetch("BASE_ECPM", 400)).to_i, "USD")
                  @multiplier = params[:multiplier]
              
                  @regions = {}
              Severity: Minor
              Found in app/controllers/wordpress_snippets_controller.rb - About 1 hr to fix

                Method perform has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def perform
                    return unless ENV["PIPEDRIVE_SYNC_HOOK_URL"].present?
                
                    body = Campaign.premium.active.includes(:user, :organization).map { |campaign|
                      {
                Severity: Minor
                Found in app/jobs/sync_to_zapier_job.rb - About 1 hr to fix

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

                    def perform
                      ScoutApm::Transaction.ignore! if rand > (ENV["SCOUT_SAMPLE_RATE"] || 1).to_f
                      properties = []
                  
                      Property.active.find_each do |property|
                  Severity: Minor
                  Found in app/jobs/property_impressions_drop_notification_job.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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def create
                      @user = User.new(user_params)
                  
                      respond_to do |format|
                        if @user.save
                  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 show has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def show
                      return head(:forbidden) unless valid_referer?
                  
                      track_event :virtual_impression_initiated
                  
                  
                  Severity: Minor
                  Found in app/controllers/advertisements_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

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

                      if (adLength > 85 || ctaLength > 20) {
                        this.copyWrapperTarget.classList.add('over-limit')
                        this.copyWarningWrapperTarget.classList.remove('text-secondary')
                        this.copyWarningWrapperTarget.classList.add('text-danger')
                      } else {
                  Severity: Major
                  Found in app/javascript/controllers/creative_form_controller.js and 1 other location - About 1 hr to fix
                  app/javascript/controllers/creative_form_controller.js on lines 59..63

                  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 60.

                  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 perform has 10 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def perform(id, campaign_id, property_id, creative_id, ad_template, ad_theme, ip_address, country_code, user_agent, displayed_at_string)
                  Severity: Major
                  Found in app/jobs/create_impression_job.rb - About 1 hr to fix

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

                      def perform(*tags)
                        ScoutApm::Transaction.ignore! if rand > (ENV["SCOUT_SAMPLE_RATE"] || 1).to_f
                        @count = 0
                        @jobs = []
                    
                    
                    Severity: Minor
                    Found in app/jobs/import_remoteok_jobs_job.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

                        } else {
                          this.copyWrapperTarget.classList.remove('over-limit')
                          this.copyWarningWrapperTarget.classList.remove('text-danger')
                          this.copyWarningWrapperTarget.classList.add('text-secondary')
                        }
                    Severity: Major
                    Found in app/javascript/controllers/creative_form_controller.js and 1 other location - About 1 hr to fix
                    app/javascript/controllers/creative_form_controller.js on lines 55..59

                    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 60.

                    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 record_conversion has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def record_conversion(impression_id_param, conversion_referrer: nil, test: false, metadata: {})
                        impression = Impression.find_by(id: impression_id_param, organization_id: organization_id) if UUID.validate(impression_id_param)
                        logger.info "Pixel#record_conversion Unable to find an impression for impression_id='#{impression_id_param}' and organization_id='#{organization_id}'." unless impression
                        impression_attribute_names = %w[
                          advertiser_id
                    Severity: Minor
                    Found in app/models/pixel.rb - About 1 hr to fix

                      Method perform has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def perform(id:, report_url:, recipients: [])
                          organization_report = OrganizationReport.find_by(id: id)
                          return unless organization_report
                      
                          organization_report.update(status: "generating")
                      Severity: Minor
                      Found in app/jobs/generate_organization_report_job.rb - About 1 hr to fix

                        Function openMenu has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          openMenu (el, emiter = true) {
                            // prevent open on active item if not on compact mode
                            if (this._hasActive(el) && !this.isCompact()) return
                            const self = this
                            let blockedSlide = this._isLevelMenu(el) && this.isCompact()
                        Severity: Minor
                        Found in app/javascript/themes/current/components/stacked-menu.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language