Showing 47 of 47 total issues
File fgraphql.ts
has 354 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { Application, HookContext, Query } from '@feathersjs/feathers';
import makeDebug from 'debug';
import type { parse, GraphQLFieldResolver } from 'graphql';
import type { SyncContextFunction } from '../types';
import { getItems } from '../utils/get-items';
Identical blocks of code found in 3 locations. Consider refactoring. Open
function replaceItem(item: any, fields: any) {
if (typeof item !== 'object' || item === null) return item;
const newItem = {};
fields.forEach((field: any) => {
- 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 111.
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 3 locations. Consider refactoring. Open
function replaceItem(item: any, fields: any) {
if (typeof item !== 'object' || item === null) return item;
const newItem = {};
fields.forEach((field: any) => {
- 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 111.
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 3 locations. Consider refactoring. Open
function replaceItem(item: any, fields: any) {
if (typeof item !== 'object' || item === null) return item;
const newItem = {};
fields.forEach((field: any) => {
- 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 111.
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 fgraphql
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fgraphql<H extends HookContext = HookContext>(options1: FGraphQLHookOptions<H>) {
debug('init call');
const { parse, recordType, resolvers, runTime, query } = options1;
let { schema } = options1;
Similar blocks of code found in 2 locations. Consider refactoring. Open
export function discardQuery<H extends HookContext = HookContext>(...fieldNames: string[]) {
return (context: H) => {
checkContext(context, 'before', null, 'discardQuery');
const query = context.params.query || {};
- 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 102.
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
export function keepQuery<H extends HookContext = HookContext>(...fieldNames: string[]) {
return (context: H) => {
checkContext(context, 'before', null, 'keepQuery');
const query = context.params.query || {};
- 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 102.
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
function replaceIn(item: any, field: any, fieldNames: any) {
const target = _get(item, field);
if (target) {
if (!Array.isArray(target))
throw new BadRequest(
- 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 100.
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
function replaceIn(item: any, field: any, fieldNames: any) {
const target = _get(item, field);
if (target) {
if (!Array.isArray(target))
throw new BadRequest(
- 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 100.
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 populateAddChild
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
function populateAddChild(
options: any,
context: HookContext,
parentItem: any,
childSchema: any,
Function cache
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function cache<H extends HookContext = HookContext, T = any>(
cacheMap: CacheMap<T>,
keyField?: string,
options?: CacheOptions<T>,
) {
Function populate
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function populate<H extends HookContext = HookContext>(options: PopulateOptions<H>) {
// options.schema is like { service: '...', permissions: '...', include: [ ... ] }
const typeofSchema = typeof options.schema;
if ((typeofSchema !== 'object' || options.schema === null) && typeofSchema !== 'function') {
Function serialize
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function serialize<H extends HookContext = HookContext>(
schema1: SerializeSchema<H> | SyncContextFunction<SerializeSchema, H>,
) {
return (context: H) => {
const schema = typeof schema1 === 'function' ? schema1(context) : schema1;
Function mongoKeys
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function mongoKeys<H extends HookContext = HookContext>(
ObjectId: new (id?: string | number) => any,
keyFields: string | string[],
) {
keyFields = Array.isArray(keyFields) ? keyFields : [keyFields];
Function processRecord
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processRecord(store: any, query: any, depth: any, rec: any, type: any, j: any): any {
debug(`processRecord rec# ${j} typeof ${typeof rec} Type ${type}`);
if (!rec) return; // Catch any null values from resolvers.
const queryPropNames = Object.keys(query);
Function processRecordFieldResolver
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processRecordFieldResolver(
store: any,
query: any,
depth: any,
rec: any,
Function debug
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function debug<H extends HookContext = HookContext>(msg: string, ...fieldNames: string[]) {
return (context: H) => {
// display timestamp
const now = new Date();
console.log(
Function alterItems
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function alterItems<T = any, H extends HookContext = HookContext>(
cb: (record: T, context: H) => any,
) {
if (!cb) {
cb = () => {};
Function processRecordQuery
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
store: any,
query: any,
depth: any,
rec: any,
fieldName: any,
Identical blocks of code found in 2 locations. Consider refactoring. Open
items.forEach((item: any) => {
const idName = getIdName(keyField, item);
const key = makeCacheKey(item[idName]);
cacheMap.delete(key);
});
- 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 59.
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