Showing 32 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
headersForRequest(params) {
const headers = this._super(params);
if (params._requestType === 'rpc') {
headers.Accept = 'application/json; charset=utf-8';
}
- Read upRead up
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 53.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
_requestFor(params) {
const res = this._super(params);
if (params._requestType === 'rpc') {
res._requestType = 'rpc';
}
- Read upRead up
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 53.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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`;
}
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!isEmpty(codes)) {
codes.forEach((code, idx) => {
errs.push(this.normalizeAdapterError(type, status, code, details[idx]));
});
} else if (!isEmpty(details)) {
- Read upRead up
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 48.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
} else if (!isEmpty(details)) {
codes.forEach((code, idx) => {
errs.push(this.normalizeAdapterError(type, status, code, details[idx]));
});
} else {
- Read upRead up
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 48.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function convertResponse
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
convertResponse(store, primaryModelClass, payload, id, requestType) {