gitcoinco/code_fund_ads

View on GitHub

Showing 211 of 211 total issues

Function init has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  init () {
    // handle polyfill
    // =============================================================

    this.placeholderShown()
Severity: Major
Found in app/javascript/themes/current/components/theme.js - About 2 hrs to fix

    Class Creative has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Creative < ApplicationRecord
      MAX_AD_COPY_LENGTH = 85
    
      # extends ...................................................................
      # includes ..................................................................
    Severity: Minor
    Found in app/models/creative.rb - About 2 hrs to fix

      Function knob has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        knob () {
          if ($.fn.knob) {
            const self = this
            $('[data-toggle="knob"]').each(function () {
              const selector = this
      Severity: Major
      Found in app/javascript/themes/current/components/theme.js - About 2 hrs to fix

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

          setHeadline () {
            if (isEmpty(this.inputHeadlineTarget.value)) {
              this.previewHeadlineTarget.textContent = 'Headline'
            } else {
              this.previewHeadlineTarget.textContent = this.inputHeadlineTarget.value
        Severity: Major
        Found in app/javascript/controllers/creative_form_controller.js and 2 other locations - About 2 hrs to fix
        app/javascript/controllers/creative_form_controller.js on lines 84..93
        app/javascript/controllers/creative_form_controller.js on lines 95..103

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

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

          jsTreeTypes () {
            return {
              '#': {
                max_children: 1,
                max_depth: 4,
        Severity: Major
        Found in app/javascript/themes/current/components/theme.js - About 2 hrs to fix

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

            setCta () {
              if (isEmpty(this.inputCtaTarget.value)) {
                this.previewCtaTarget.textContent = 'Learn more'
              } else {
                this.previewCtaTarget.textContent = this.inputCtaTarget.value
          Severity: Major
          Found in app/javascript/controllers/creative_form_controller.js and 2 other locations - About 2 hrs to fix
          app/javascript/controllers/creative_form_controller.js on lines 74..82
          app/javascript/controllers/creative_form_controller.js on lines 84..93

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

          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 3 locations. Consider refactoring.
          Open

            setBody () {
              if (isEmpty(this.inputBodyTarget.value)) {
                this.previewBodyTarget.textContent =
                  '🚀 Your body will go here. You can use an emoji to help catch their eye 🤪'
              } else {
          Severity: Major
          Found in app/javascript/controllers/creative_form_controller.js and 2 other locations - About 2 hrs to fix
          app/javascript/controllers/creative_form_controller.js on lines 74..82
          app/javascript/controllers/creative_form_controller.js on lines 95..103

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

          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

                btnUp.on('click', function () {
                  const oldValue = parseFloat(input.val()) || 0
                  newVal = oldValue >= max ? oldValue : oldValue + step
          
                  input.val(newVal).trigger('change')
          Severity: Major
          Found in app/javascript/themes/current/components/theme.js and 1 other location - About 2 hrs to fix
          app/javascript/themes/current/components/theme.js on lines 328..333

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

          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

                btnDown.on('click', function () {
                  const oldValue = parseFloat(input.val()) || 0
                  newVal = oldValue <= min ? oldValue : oldValue - step
          
                  input.val(newVal).trigger('change')
          Severity: Major
          Found in app/javascript/themes/current/components/theme.js and 1 other location - About 2 hrs to fix
          app/javascript/themes/current/components/theme.js on lines 321..326

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

          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

          `` has 21 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class extends Controller {
            static targets = ['input', 'hidden', 'results']
          
            connect () {
              this.initCommandK()
          Severity: Minor
          Found in app/javascript/controllers/search_autocomplete_controller.js - About 2 hrs to fix

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

                Country.all.each do |country|
                  @regions[country.region] ||= {}
                  @regions[country.region][country.subregion] ||= {display_price: country.ecpm(base: @base, multiplier: @multiplier).format, countries: []}
                  c = {
                    id: country.id,
            Severity: Major
            Found in app/controllers/pricings_controller.rb and 1 other location - About 2 hrs to fix
            app/controllers/wordpress_snippets_controller.rb on lines 23..36

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

            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

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

                Country.all.each do |country|
                  @regions[country.region] ||= {}
                  @regions[country.region][country.subregion] ||= {display_price: country.ecpm(base: @base, multiplier: @multiplier).format, countries: []}
                  c = {
                    id: country.id,
            Severity: Major
            Found in app/controllers/wordpress_snippets_controller.rb and 1 other location - About 2 hrs to fix
            app/controllers/pricings_controller.rb on lines 8..21

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

            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 set_campaign has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_campaign
                return nil if device.bot?
                return nil unless property&.active? || property&.pending?
                return nil if device_small? && property.hide_on_responsive?
                return nil if back_pressure?
            Severity: Minor
            Found in app/controllers/advertisements_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 import_jobs has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def import_jobs(tags)
                @jobs = []
            
                fetch_jobs(tags)
            
            
            Severity: Minor
            Found in app/jobs/import_github_jobs_job.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 create has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def create
                return render_forbidden unless authorized_user.can_purchase_job_posting?(@job_posting)
            
                if params[:source_id].blank?
                  flash.now[:error] = "Payment info not submitted! Please try again."
            Severity: Minor
            Found in app/controllers/job_posting_purchases_controller.rb - About 2 hrs to fix

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

                def perform(impressionable, start_date_string, end_date_string, scoped_by, scoped_by_type = nil)
                  start_date = Date.coerce(start_date_string)
                  end_date = Date.coerce(end_date_string)
                  (start_date..end_date).each do |date|
                    next if date.today? || date.future?
              Severity: Minor
              Found in app/jobs/create_daily_summaries_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

              Function draw has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      options.draw = function () {
                        // 'tron' case
                        if (this.$.data('skin') == 'tron') {
                          this.cursorExt = 0.3
                          let a = this.arc(this.cv) // Arc
              Severity: Minor
              Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

                Function _slide has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  _slide (el, direction, speed, easing) {
                    speed = speed || 300
                    easing = easing || 'ease'
                    let self = this
                    let menu = el.querySelector('.menu')
                Severity: Minor
                Found in app/javascript/themes/current/components/stacked-menu.js - About 1 hr to fix

                  Function onKeydown has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    onKeydown (event) {
                      switch (event.key) {
                        case 'Escape':
                          if (!this.resultsTarget.hidden) {
                            this.resultsTarget.hidden = true
                  Severity: Minor
                  Found in app/javascript/controllers/search_autocomplete_controller.js - About 1 hr to fix

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

                      def perform(campaign_id, date_string)
                        ScoutApm::Transaction.ignore! if rand > (ENV["SCOUT_SAMPLE_RATE"] || 1).to_f
                        date = Date.parse(date_string)
                        return unless date.past?
                    
                    
                    Severity: Minor
                    Found in app/jobs/create_debit_for_campaign_and_date_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

                    Severity
                    Category
                    Status
                    Source
                    Language