infinum/ember-form-object

View on GitHub

Showing 15 of 17 total issues

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

export default Mixin.create({
  isSubmitting: false,
  isDirty: false,
  isLoaded: false,
  isSaveError: false,
Severity: Minor
Found in addon/mixins/form-object.js - About 3 hrs to fix

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

    export default ObjectProxy.extend(EmberValidations, FormObjectMixin, {
      isNew: readOnly('model.isNew'),
    
      propertiesServerErrors: computed(function() {
        return {};
    Severity: Minor
    Found in addon/forms/model-form.js - About 3 hrs to fix

      Function areTwoValuesEqual has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      function areTwoValuesEqual(a, b, opts = {}) {
        const { takeOrderIntoAccount } = opts;
      
        if (a === b) {
          return true;
      Severity: Minor
      Found in addon/utils/dirty-comparison.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

      File form-object.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import Ember from 'ember';
      import { superWasCalled, ensureSuperWasCalled } from 'ember-form-object/utils/super';
      import { normalizeValueForDirtyComparison, areTwoValuesEqual } from 'ember-form-object/utils/dirty-comparison';
      import {
        isThenable, runSafe, isFunction, isPlainObject, some, every, result, cloneDeep
      Severity: Minor
      Found in addon/mixins/form-object.js - About 2 hrs to fix

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

        function areTwoValuesEqual(a, b, opts = {}) {
          const { takeOrderIntoAccount } = opts;
        
          if (a === b) {
            return true;
        Severity: Minor
        Found in addon/utils/dirty-comparison.js - About 1 hr to fix

          Function save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            save() {
              if (!this.get('isDirty') && !this.get('allowSaveIfNotDirty')) {
                return RSVP.reject('Form object is not dirty');
              }
          
          
          Severity: Minor
          Found in addon/mixins/form-object.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

              if (res && ((res.errors && res.errors.length && res.errors[0].status) || res.isAdapterError)) {
                const isServerValidationError = res.errors && res.errors.length && res.errors[0].status === '422';
                return new EmberObject({
                  isAdapterError: true,
                  isServerValidationError,
            Severity: Major
            Found in addon/utils/errors.js - About 1 hr to fix

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

              function some(obj, clb) {
                const isObjArray = isArray(obj);
                const keys = isObjArray ? obj : objectKeys(obj);
              
                for (let i = 0; i < keys.length; i += 1) {
              Severity: Minor
              Found in addon/utils/core.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

              Avoid too many return statements within this function.
              Open

                        return false;
              Severity: Major
              Found in addon/utils/dirty-comparison.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return true;
                Severity: Major
                Found in addon/utils/dirty-comparison.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return true;
                  Severity: Major
                  Found in addon/utils/dirty-comparison.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return false;
                    Severity: Major
                    Found in addon/utils/dirty-comparison.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return true;
                      Severity: Major
                      Found in addon/utils/dirty-comparison.js - About 30 mins to fix

                        Function _initProperty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          _initProperty(initialProp, key) {
                            const prop = this.normalizePropertyDefinition(isPlainObject(initialProp) ? initialProp : {});
                            prop.state = this._getInitialPropertyState(prop);
                        
                            if (prop.virtual) {
                        Severity: Minor
                        Found in addon/mixins/form-object.js - About 25 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

                        Function serverResponseError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function serverResponseError(res) {
                          if (res && ((res.errors && res.errors.length && res.errors[0].status) || res.isAdapterError)) {
                            const isServerValidationError = res.errors && res.errors.length && res.errors[0].status === '422';
                            return new EmberObject({
                              isAdapterError: true,
                        Severity: Minor
                        Found in addon/utils/errors.js - About 25 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

                        Severity
                        Category
                        Status
                        Source
                        Language