rx/presenters

View on GitHub

Showing 126 of 126 total issues

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

    isDirty() {
        if (!this.dirtyable) {
            return false;
        }
        const currVal = new Date(this.fp.input.value);
Severity: Major
Found in views/mdc/assets/js/components/datetime.js and 1 other location - About 2 hrs to fix
views/mdc/assets/js/components/datetime.js on lines 167..174

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

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

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

      class App < Sinatra::Base
        include Trace
        set :root, File.expand_path('../../../../..', __FILE__)
        set :router_, WebClient::Router
        set :bind, '0.0.0.0'
Severity: Minor
Found in lib/voom/presenters/web_client/app.rb - About 2 hrs to fix

    Function initLists has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    export function initLists(e) {
        console.debug('\tLists');
        let components = e.querySelectorAll('.mdc-list');
    
        if (components.length === 0 && e.offsetParent && e.offsetParent.vComponent !== undefined) {
    Severity: Minor
    Found in views/mdc/assets/js/components/lists.js - 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

    Function call has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        call(results) {
            const targetId = this.targetId;
            const action = this.params.action;
            const delayAmt = this.event instanceof FocusEvent ? 500 : 0;
            const elem = this.root.getElementById(targetId);
    Severity: Major
    Found in views/mdc/assets/js/components/events/toggle_visibility.js - About 2 hrs to fix

      Class UserInterface has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class UserInterface
              include DSL::Definer
              include DSL::ProtectFromForgery
              include Components::Mixins::Common
              include Components::Mixins::Helpers
      Severity: Minor
      Found in lib/voom/presenters/dsl/user_interface.rb - About 2 hrs to fix

        Method expand_hash has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def expand_hash(h)
              HashExt::Traverse.traverse(h.to_h) do |k,v|
                if !v.is_a?(Array) && v.respond_to?(:to_h)
                  v = v.is_a?(OpenStruct) ? expand_hash(v.to_h) : v.to_h
                elsif v.is_a?(Array)
        Severity: Minor
        Found in lib/voom/presenters/web_client/helpers/expand_hash.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

        Function next has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    MaterialStepper.prototype.next = function () {
                        /** @type {boolean} */
                        var moved;
                        /** @type {MaterialStepper.Steps_.collection<step>} */
                        var step;
        Severity: Minor
        Found in views/mdc/assets/js/mdl-stepper.js - About 1 hr to fix

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

                      httpRequest.onreadystatechange = (event) => {
                          if (httpRequest.readyState === XMLHttpRequest.DONE) {
                              const contentType = httpRequest.getResponseHeader('content-type');
                              console.debug(httpRequest.status + ':' + contentType);
          
          
          Severity: Minor
          Found in views/mdc/assets/js/components/events/posts.js - About 1 hr to fix

            Function action_class has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static action_class(action, event, root) {
                    const action_type = action[0];
                    const url = action[1];
                    const options = action[2];
                    const params = action[3];
            Severity: Minor
            Found in views/mdc/assets/js/components/events.js - About 1 hr to fix

              Function getStepModel_ has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                          MaterialStepper.prototype.getStepModel_ = function (step, id) {
                              /** @type {Object} */
                              var model;
                              /** @type {string} */
                              var selectorActionsBack;
              Severity: Minor
              Found in views/mdc/assets/js/mdl-stepper.js - About 1 hr to fix

                Function buildURL has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    buildURL(baseUrl) {
                        var url = baseUrl;
                        for (var i = 1; i < arguments.length; i++) {
                            var args = arguments[i];
                            if (Array.isArray(args)) {
                Severity: Minor
                Found in views/mdc/assets/js/utils/urls.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 vTimeout has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                                nodeToReplace.vTimeout = setTimeout(function() {
                                    httpRequest.onreadystatechange = function() {
                                        if (httpRequest.readyState === XMLHttpRequest.DONE) {
                                            console.debug(httpRequest.status + ':' +
                                                this.getResponseHeader('content-type'));
                Severity: Minor
                Found in views/mdc/assets/js/components/events/replaces.js - About 1 hr to fix

                  Function displayErrors has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      displayErrors(result) {
                          const {statusCode, contentType, content} = result;
                  
                          let responseErrors = null;
                  
                  
                  Severity: Minor
                  Found in views/mdc/assets/js/components/events/errors.js - About 1 hr to fix

                    Function initialize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function initialize(root, setRoot) {
                        console.debug('Initializing components');
                    
                        const start = performance.now();
                    
                    
                    Severity: Minor
                    Found in views/mdc/assets/js/components/initialize.js - About 1 hr to fix

                      Function initEvents has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function initEvents(e) {
                          console.debug('\tEvents');
                      
                          for (const eventElem of getEventElements(e)) {
                              var eventsData = JSON.parse(eventElem.dataset.events);
                      Severity: Minor
                      Found in views/mdc/assets/js/components/events.js - About 1 hr to fix

                        Function promiseObj has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                const promiseObj = new Promise(function(resolve) {
                                    clearTimeout(elem.vTimeout);
                                    elem.vTimeout = setTimeout(function() {
                                        console.debug('Toggling visibility on: ' + targetId);
                        
                        
                        Severity: Minor
                        Found in views/mdc/assets/js/components/events/toggle_visibility.js - About 1 hr to fix

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

                              constructor(options, params, event, root) {
                                  this.target = options.target;
                                  this.ids = params.ids;
                                  this.event = event;
                                  this.root = root;
                          Severity: Major
                          Found in views/mdc/assets/js/components/events/clears.js and 1 other location - About 1 hr to fix
                          views/mdc/assets/js/components/events/removes.js on lines 2..7

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

                          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

                              constructor(options, params, event, root) {
                                  this.target = options.target;
                                  this.ids = params.ids;
                                  this.event = event;
                                  this.root = root;
                          Severity: Major
                          Found in views/mdc/assets/js/components/events/removes.js and 1 other location - About 1 hr to fix
                          views/mdc/assets/js/components/events/clears.js on lines 2..7

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

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

                          export let visibilityObserverMixin = Base => class extends Base {
                          
                              recalcWhenVisible(vComponent) {
                                  vComponent.hidden_on_create = vComponent.element.offsetParent === null;
                                  if (vComponent.hidden_on_create) {
                          Severity: Minor
                          Found in views/mdc/assets/js/components/mixins/visibility-observer.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 back has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                      MaterialStepper.prototype.back = function () {
                                          /** @type {boolean} */
                                          var moved;
                                          /** @type {function} */
                                          var moveStep;
                          Severity: Minor
                          Found in views/mdc/assets/js/mdl-stepper.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language