infinum/ember-form-object

View on GitHub

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

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

              prop.set = (isFunction(prop.set) && prop.set) || this[`set${key[0].toUpperCase()}${key.slice(1)}`];
        Severity: Major
        Found in addon/mixins/form-object.js and 1 other location - About 1 hr to fix
        addon/forms/model-form.js on lines 205..205

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

        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

              prop.sync = (isFunction(prop.sync) && prop.sync) || this[`sync${key[0].toUpperCase()}${key.slice(1)}`];
        Severity: Major
        Found in addon/forms/model-form.js and 1 other location - About 1 hr to fix
        addon/mixins/form-object.js on lines 254..254

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

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