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 {
- Read upRead up
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 = {
- Read upRead up
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';
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`);
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;
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-_') {
- Read upRead up
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 {
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);
}
- Read upRead up
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) {
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;
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 = {
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 = {
- Read upRead up
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);
}
Function normalizeResponseHelper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
Avoid deeply nested control flow statements. Open
if (opts.kind === 'belongsTo') {
link += `&page_size=1`;
}
Function convertResponse
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
convertResponse(store, primaryModelClass, payload, id, requestType) {
Function buildJSON
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
buildJSON(store, primaryModelClass, type, json, included) {
Function normalizeResponse
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
Function buildNested
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
buildNested(store, primaryModelClass, type, json, included) {
Function buildNestedArray
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
buildNestedArray(store, primaryModelClass, type, json, included) {