gitcoinco/code_fund_ads

View on GitHub

Showing 211 of 211 total issues

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

  def body
    if mail.multipart? && mail.html_part
      document = Nokogiri::HTML(mail.html_part.body.decoded)

      attachments.map do |attachment_hash|
Severity: Minor
Found in app/mailboxes/incoming_mailbox.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 constructor has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  constructor (options) {
    /**
     * The StackedMenu options.
     * @type {Object}
     * @property {Boolean} compact=false                  - Transform StackedMenu items (except item childs) to small size.
Severity: Minor
Found in app/javascript/themes/current/components/stacked-menu.js - About 1 hr to fix

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

      def perform(property_id)
        property = Property.find(property_id)
        data = TrafficEstimator.lookup(property.url)[:data]
        return if data.blank?
        estimate = PropertyTrafficEstimate.new
    Severity: Minor
    Found in app/jobs/estimate_traffic_for_property_job.rb - About 1 hr to fix

      Method import_jobs has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def import_jobs(tags)
          @jobs = []
      
          fetch_jobs(tags)
      
      
      Severity: Minor
      Found in app/jobs/import_github_jobs_job.rb - About 1 hr to fix

        Method set_meta_tag_data has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def set_meta_tag_data
            set_meta_tags(
              site: "CodeFund",
              title: "CodeFund | Ethical Advertising",
              description: "CodeFund is an open source platform that helps fund maintainers, bloggers, and builders through non-tracking ethical ads",
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 1 hr to fix

          Method validate_assigned_properties has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_assigned_properties
              return unless sponsor?
              return unless active?
              return if fallback?
              return if paid_fallback?
          Severity: Minor
          Found in app/models/campaign.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 13 (exceeds 5 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)
              ScoutApm::Transaction.ignore! if rand > (ENV["SCOUT_SAMPLE_RATE"] || 1).to_f
              return unless user_agent
          
              campaign = Campaign.find_by(id: campaign_id)
          Severity: Minor
          Found in app/jobs/create_impression_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 openMenu has a Cognitive Complexity of 13 (exceeds 5 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

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

            detectUplift (count) {
              if (!this.urls.adblock) return
              if (this.urls.adblock.length === 0) return
              var xhr = new XMLHttpRequest()
              xhr.onreadystatechange = () => {
          Severity: Minor
          Found in app/javascript/advertisements/index.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

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

            selectAll (event) {
              Rails.stopEverything(event)
              this.options.forEach(o => (o.selected = true))
              this.selectTarget.dispatchEvent(new Event('change'))
            }
          Severity: Major
          Found in app/javascript/controllers/select_multiple_controller.js and 1 other location - About 1 hr to fix
          app/javascript/controllers/select_multiple_controller.js on lines 25..29

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

          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

            clearSelections (event) {
              Rails.stopEverything(event)
              this.options.forEach(o => (o.selected = false))
              this.selectTarget.dispatchEvent(new Event('change'))
            }
          Severity: Major
          Found in app/javascript/controllers/select_multiple_controller.js and 1 other location - About 1 hr to fix
          app/javascript/controllers/select_multiple_controller.js on lines 8..12

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

          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

              } else {
                // slide down
                this._slide(el, 'down', 150, 'linear').then(function () {
                  self._addClass(el, self.classes.hasOpen)
                  // handle tabindex
          Severity: Major
          Found in app/javascript/themes/current/components/stacked-menu.js and 1 other location - About 1 hr to fix
          app/javascript/themes/current/components/stacked-menu.js on lines 691..698

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

          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

                if (!this._hasActive(el)) {
                  // slide up
                  this._slide(el, 'up', 150, 'linear').then(function () {
                    self._removeClass(el, self.classes.hasOpen)
                    // handle tabindex
          Severity: Major
          Found in app/javascript/themes/current/components/stacked-menu.js and 1 other location - About 1 hr to fix
          app/javascript/themes/current/components/stacked-menu.js on lines 620..627

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

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

            def perform(impressionable, date_string, scoped_by, scoped_by_type = nil)
              date = Date.coerce(date_string)
              return if date.today? || date.future?
              return if impressionable.daily_summaries.on(date).scoped_by(scoped_by, scoped_by_type).exists?
              return if impressionable.is_a?(Campaign) && !impressionable.available_on?(date)
          Severity: Minor
          Found in app/jobs/create_daily_summary_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 onKeydown has a Cognitive Complexity of 12 (exceeds 5 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

          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 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform(impression_id, campaign_id, 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&.standard?
          
          
          Severity: Minor
          Found in app/jobs/create_click_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 cloudfront_url has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def cloudfront_url
                return service_url unless cloudfront_host
                return service_url unless defined?(ActiveStorage::Service::S3Service)
                return service_url unless service.is_a?(ActiveStorage::Service::S3Service)
                uri = URI(service_url)
          Severity: Minor
          Found in app/lib/extensions/active_storage_blob.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 35 lines of code (exceeds 25 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)
              ScoutApm::Transaction.ignore! if rand > (ENV["SCOUT_SAMPLE_RATE"] || 1).to_f
              return unless user_agent
          
              campaign = Campaign.find_by(id: campaign_id)
          Severity: Minor
          Found in app/jobs/create_impression_job.rb - About 1 hr to fix

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

              showSidebar (relatedTarget) {
                $('.has-sidebar').addClass('has-sidebar-open')
            
                // trigger event
                $('.page-sidebar').trigger({
            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 672..681

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

            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

              hideSidebar (relatedTarget) {
                $('.has-sidebar').removeClass('has-sidebar-open')
            
                // trigger event
                $('.page-sidebar').trigger({
            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 658..667

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

            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