gitcoinco/code_fund_ads

View on GitHub
app/javascript/themes/current/components/theme.js

Summary

Maintainability
F
1 wk
Test Coverage

File theme.js has 1273 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import StackedMenu from './stacked-menu'
import PerfectScrollbar from 'perfect-scrollbar'
import lozad from 'lozad'

class Theme {
Severity: Major
Found in app/javascript/themes/current/components/theme.js - About 3 days to fix

    Theme has 87 functions (exceeds 20 allowed). Consider refactoring.
    Open

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

      Function maskInput has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        maskInput () {
          if (window.vanillaTextMask) {
            $('[data-mask]').each(function () {
              const selector = this
              const options = $(selector).data()
      Severity: Major
      Found in app/javascript/themes/current/components/theme.js - About 3 hrs to fix

        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

          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

            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

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

                  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

                    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

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

                          tribute () {
                            if (window.Tribute) {
                              $('[data-toggle="tribute"]').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

                          Function objectFitFallback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            objectFitFallback () {
                              if (this.isIE() || this.isEdge()) {
                                const selectors = [
                                  '.user-avatar img',
                                  '.tile > img',
                          Severity: Minor
                          Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

                            Function publisher has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              publisher () {
                                $(document)
                                  .on('focusin', '.publisher .form-control', function () {
                                    const $publisher = $(this).parents('.publisher')
                            
                            
                            Severity: Minor
                            Found in app/javascript/themes/current/components/theme.js - About 1 hr to fix

                              Consider simplifying this complex logical expression.
                              Open

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

                                Function browserFlagging has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  browserFlagging () {
                                    if (this.isOpera()) {
                                      $('body').addClass('opera')
                                    }
                                
                                
                                Severity: Minor
                                Found in app/javascript/themes/current/components/theme.js - About 35 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

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

                                  nestable () {
                                    if ($.fn.nestable) {
                                      $('[data-toggle="nestable"]').each(function () {
                                        const selector = this
                                        const options = $(selector).data()
                                Severity: Major
                                Found in app/javascript/themes/current/components/theme.js and 2 other locations - About 2 hrs to fix
                                app/javascript/themes/current/components/theme.js on lines 1296..1305
                                app/javascript/themes/current/components/theme.js on lines 1399..1408

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

                                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

                                  atwho () {
                                    if ($.fn.atwho) {
                                      $('[data-toggle="atwho"]').each(function () {
                                        const selector = this
                                        const options = $(selector).data()
                                Severity: Major
                                Found in app/javascript/themes/current/components/theme.js and 2 other locations - About 2 hrs to fix
                                app/javascript/themes/current/components/theme.js on lines 1158..1167
                                app/javascript/themes/current/components/theme.js on lines 1399..1408

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

                                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

                                  colorpicker () {
                                    if ($.fn.colorpicker) {
                                      $('[data-toggle="colorpicker"]').each(function () {
                                        const selector = this
                                        const options = $(selector).data()
                                Severity: Major
                                Found in app/javascript/themes/current/components/theme.js and 2 other locations - About 2 hrs to fix
                                app/javascript/themes/current/components/theme.js on lines 1158..1167
                                app/javascript/themes/current/components/theme.js on lines 1296..1305

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

                                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

                                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

                                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

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

                                              this.g.arc(
                                                this.xy,
                                                this.xy,
                                                this.radius - this.lineWidth,
                                                pa.s,
                                Severity: Minor
                                Found in app/javascript/themes/current/components/theme.js and 1 other location - About 50 mins to fix
                                app/javascript/themes/current/components/theme.js on lines 1106..1113

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

                                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

                                            this.g.arc(
                                              this.xy,
                                              this.xy,
                                              this.radius - this.lineWidth,
                                              a.s,
                                Severity: Minor
                                Found in app/javascript/themes/current/components/theme.js and 1 other location - About 50 mins to fix
                                app/javascript/themes/current/components/theme.js on lines 1093..1100

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

                                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

                                There are no issues that match your filters.

                                Category
                                Status