Showing 32 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';
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;
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,
Function combine
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function combine<H extends HookContext = HookContext>(...serviceHooks: HookFunction<H>[]) {
// if (serviceHooks.length && Array.isArray(serviceHooks[0])) {
// serviceHooks = serviceHooks[0];
// }
Function stashBefore
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function stashBefore<H extends HookContext = HookContext>(fieldName?: string) {
const beforeField = fieldName || 'before';
return (context: H) => {
checkContext(context, 'before', ['get', 'update', 'patch', 'remove'], 'stashBefore');
Function populateItem
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function populateItem(
options: any,
context: HookContext,
item: any,
includeSchema: any,
Function serializeItem
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function serializeItem(item: any, schema: any) {
const computed: Record<string, any> = {};
Object.keys(schema.computed || {}).forEach(name => {
computed[name] = schema.computed[name](item, context); // needs closure
});
Function checkContext
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function checkContext<H extends HookContext = HookContext>(
context: H,
type?: HookType | HookType[] | null,
methods?: MethodName | MethodName[] | null,
label = 'anonymous',
- 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 convertResolverResult
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function convertResolverResult(result: any, ourQuery: any, fieldName: any, type: any) {
if (result === null || result === undefined) {
return ourQuery.listType ? [] : null;
}
- 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 fgraphql
has a Cognitive Complexity of 9 (exceeds 5 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;
- 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 processRecord
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function processRecord(store: any, query: any, depth: any, rec: any, type: any, j: any): any {