busy-web/data

View on GitHub

Showing 27 of 32 total issues

Function validateDocumentStructure has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

function validateDocumentStructure(doc) {
  let errors = [];
  if (!doc || typeof doc !== 'object') {
    errors.push('Top level of a JSON API document must be an object');
  } else {
Severity: Minor
Found in addon/mixins/store-finders.js - About 6 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 buildJSON has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    buildJSON(store, primaryModelClass, type, json, included) {
        const primaryKey = get(this, 'primaryKey');

        // create a data type object
        const model = {
Severity: Minor
Found in addon/mixins/json-api-serializer.js - About 3 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 store-finders.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module store
 *
 */
import { getOwner } from '@ember/application';
Severity: Minor
Found in addon/mixins/store-finders.js - About 2 hrs to fix

    Function addRelationships has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        addRelationships(store, primaryModelClass, json) {
            const data = {};
            primaryModelClass.eachRelationship((type, opts) => {
                // get the model name + -id and underscore it.
                let name = underscore(`${opts.type}-id`);
    Severity: Major
    Found in addon/mixins/json-api-serializer.js - About 2 hrs to fix

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

          initialize(/*registry*/) {
              DS.RPCModel = DS.Model.extend(RPCModelMixin, {});
      
              const belongsTo = DS.belongsTo;
      
      
      Severity: Major
      Found in addon/initializers/@busy-web/data.js - About 2 hrs to fix

        Function serializeAttribute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            serializeAttribute(snapshot, json, key, attribute) {
                const type = attribute.type;
                if (this._canSerialize(key)) {
                    let value = snapshot.attr(key);
                    if (!isNone(type) && value !== undefined && value !== '_-NULL-_' && value !== '!_-NULL-_' && value !== '_-DISABLE-_')  {
        Severity: Minor
        Found in addon/serializers/json.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 validateDocumentStructure has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function validateDocumentStructure(doc) {
          let errors = [];
          if (!doc || typeof doc !== 'object') {
            errors.push('Top level of a JSON API document must be an object');
          } else {
        Severity: Minor
        Found in addon/mixins/store-finders.js - About 1 hr to fix

          Function typeCast has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function typeCast(value) {
              if (/^[.][\d]+/.test(value)) {
                  return typeCast(0 + value);
              }
          
          
          Severity: Minor
          Found in addon/utils/query.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 _sendBatch has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _sendBatch() {
                  const { requests, responses } = this._requestStore.flushPending();
                  this.rpcRequest(this.store, 'batch', 'batch-rest', { requests }).then(batch => {
                      const results = get(batch, 'data.results');
                      if (batch.success && results) {
          Severity: Minor
          Found in addon/mixins/batch.js - About 1 hr to fix

            Function nextParams has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function nextParams(model, query, lastQuery) {
                let isJsonApi = false;
                let next = get(model, 'meta.next');
                if (isNone(next)) {
                    isJsonApi = true;
            Severity: Minor
            Found in addon/mixins/store-finders.js - About 1 hr to fix

              Function buildJSON has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  buildJSON(store, primaryModelClass, type, json, included) {
                      const primaryKey = get(this, 'primaryKey');
              
                      // create a data type object
                      const model = {
              Severity: Minor
              Found in addon/mixins/json-api-serializer.js - About 1 hr to fix

                Function normalizeResponse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    normalizeResponse(store, primaryModelClass, payload, id, requestType) {
                        let response;
                        if (!payload.jsonapi) {
                            if (requestType === 'deleteRecord') { // delete record should return a no content response
                                response = {
                Severity: Minor
                Found in addon/mixins/json-api-serializer.js - About 55 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 deeply nested control flow statements.
                Open

                                        if (!get(value, primaryKey)) {
                                            value.id = v4.apply(v4, arguments);
                                        }
                Severity: Major
                Found in addon/mixins/json-api-serializer.js - About 45 mins to fix

                  Function normalizeResponseHelper has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
                  Severity: Minor
                  Found in addon/mixins/store-finders.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (opts.kind === 'belongsTo') {
                                                    link += `&page_size=1`;
                                                }
                    Severity: Major
                    Found in addon/mixins/json-api-serializer.js - About 45 mins to fix

                      Function convertResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          convertResponse(store, primaryModelClass, payload, id, requestType) {
                      Severity: Minor
                      Found in addon/mixins/json-api-serializer.js - About 35 mins to fix

                        Function buildJSON has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            buildJSON(store, primaryModelClass, type, json, included) {
                        Severity: Minor
                        Found in addon/mixins/json-api-serializer.js - About 35 mins to fix

                          Function normalizeResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              normalizeResponse(store, primaryModelClass, payload, id, requestType) {
                          Severity: Minor
                          Found in addon/mixins/json-api-serializer.js - About 35 mins to fix

                            Function buildNested has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                buildNested(store, primaryModelClass, type, json, included) {
                            Severity: Minor
                            Found in addon/mixins/json-api-serializer.js - About 35 mins to fix

                              Function buildNestedArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  buildNestedArray(store, primaryModelClass, type, json, included) {
                              Severity: Minor
                              Found in addon/mixins/json-api-serializer.js - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language