feathersjs/feathers

View on GitHub

Showing 32 of 36 total issues

File adapter.ts has 503 lines of code (exceeds 300 allowed). Consider refactoring.
Open

import {
  ObjectId,
  Collection,
  FindOptions,
  BulkWriteOptions,
Severity: Major
Found in packages/mongodb/src/adapter.ts - About 6 hrs to fix

    File config.sidebar.ts has 491 lines of code (exceeds 300 allowed). Consider refactoring.
    Open

    const comparisonSidebar = [
      {
        text: 'Compare Feathers',
        items: [
          {
    Severity: Minor
    Found in docs/.vitepress/config.sidebar.ts - About 6 hrs to fix

      Function feathersExpress has a Cognitive Complexity of 29 (exceeds 8 allowed). Consider refactoring.
      Open

      export default function feathersExpress<S = any, C = any>(
        feathersApp?: FeathersApplication<S, C>,
        expressApp: Express = express()
      ): Application<S, C> {
        if (!feathersApp) {
      Severity: Minor
      Found in packages/express/src/index.ts - 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

      Function _find has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
      Open

        async _find(params: ServiceParams = {} as ServiceParams): Promise<Paginated<Result> | Result[]> {
          const { paginate } = this.getOptions(params)
          const { query, filters } = this.getQuery(params)
      
          let values = _.values(this.store)
      Severity: Minor
      Found in packages/memory/src/index.ts - 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 useQuery has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring.
      Open

      export const useQuery = <T extends FieldType>(reference: Ref<T>, field: string) => {
        function getQuery() {
          return queryString.parse(window.location.search, {
            parseNumbers: true,
            parseBooleans: true,
      Severity: Minor
      Found in docs/ecosystem/useQuery.ts - 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 generate has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring.
      Open

      export const generate = (ctx: ServiceGeneratorArguments) =>
        Promise.resolve(ctx)
          .then(initializeBaseContext())
          .then(checkPreconditions())
          .then(
      Severity: Minor
      Found in packages/generators/src/service/index.ts - 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 resolveExternal has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring.
      Open

        <H extends HookContext>(...resolvers: Resolver<any, H>[]) =>
        async (context: H, next: NextFunction) => {
          if (typeof next !== 'function') {
            throw new Error('The resolveExternal hook must be used as an around hook')
          }
      Severity: Minor
      Found in packages/schema/src/hooks/resolve.ts - 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 errorHandler has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
      Open

      export function errorHandler(error: any) {
        const { message } = error
        let feathersError = error
      
        if (error.sqlState && error.sqlState.length) {
      Severity: Minor
      Found in packages/knex/src/error-handler.ts - 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

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

        Promise.resolve(ctx)
          .then(initializeBaseContext())
          .then(checkPreconditions())
          .then(
            prompt((ctx: AuthenticationGeneratorArguments) => [
      Severity: Major
      Found in packages/generators/src/authentication/index.ts and 3 other locations - About 1 hr to fix
      packages/generators/src/connection/index.ts on lines 83..86
      packages/generators/src/hook/index.ts on lines 18..40
      packages/generators/src/service/index.ts on lines 91..184

      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 36.

      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

      Further Reading

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

        Promise.resolve(ctx)
          .then(initializeBaseContext())
          .then(checkPreconditions())
          .then(
            prompt<HookGeneratorContext>(({ type, name }) => [
      Severity: Major
      Found in packages/generators/src/hook/index.ts and 3 other locations - About 1 hr to fix
      packages/generators/src/authentication/index.ts on lines 28..82
      packages/generators/src/connection/index.ts on lines 83..86
      packages/generators/src/service/index.ts on lines 91..184

      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 36.

      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

      Further Reading

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

        Promise.resolve(ctx)
          .then(initializeBaseContext())
          .then(checkPreconditions())
          .then(prompt(prompts))
      Severity: Major
      Found in packages/generators/src/connection/index.ts and 3 other locations - About 1 hr to fix
      packages/generators/src/authentication/index.ts on lines 28..82
      packages/generators/src/hook/index.ts on lines 18..40
      packages/generators/src/service/index.ts on lines 91..184

      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 36.

      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

      Further Reading

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

        Promise.resolve(ctx)
          .then(initializeBaseContext())
          .then(checkPreconditions())
          .then(
            prompt(({ name, path, type, schema, authentication, isEntityService, feathers, lib, language }) => {
      Severity: Major
      Found in packages/generators/src/service/index.ts and 3 other locations - About 1 hr to fix
      packages/generators/src/authentication/index.ts on lines 28..82
      packages/generators/src/connection/index.ts on lines 83..86
      packages/generators/src/hook/index.ts on lines 18..40

      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 36.

      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

      Further Reading

      Function redirectHook has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
      Open

      export const redirectHook = () => async (context: HookContext, next: NextFunction) => {
        try {
          await next()
      
          const { location } = context.result
      Severity: Minor
      Found in packages/authentication-oauth/src/service.ts - 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

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      export type ServiceInterface<
        Result = any,
        Data = Partial<Result>,
        ServiceParams = Params,
        PatchData = Partial<Data>
      Severity: Major
      Found in packages/feathers/src/declarations.ts and 3 other locations - About 55 mins to fix
      packages/feathers/src/declarations.ts on lines 73..94
      packages/feathers/src/declarations.ts on lines 96..115
      packages/feathers/src/declarations.ts on lines 121..126

      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 33.

      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

      Further Reading

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      export type Service<
        Result = any,
        Data = Partial<Result>,
        ServiceParams = Params,
        PatchData = Partial<Data>
      Severity: Major
      Found in packages/feathers/src/declarations.ts and 3 other locations - About 55 mins to fix
      packages/feathers/src/declarations.ts on lines 73..94
      packages/feathers/src/declarations.ts on lines 96..115
      packages/feathers/src/declarations.ts on lines 131..136

      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 33.

      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

      Further Reading

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      export interface ServiceOverloads<
        Result = any,
        Data = Partial<Result>,
        ServiceParams = Params,
        PatchData = Partial<Data>
      Severity: Major
      Found in packages/feathers/src/declarations.ts and 3 other locations - About 55 mins to fix
      packages/feathers/src/declarations.ts on lines 73..94
      packages/feathers/src/declarations.ts on lines 121..126
      packages/feathers/src/declarations.ts on lines 131..136

      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 33.

      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

      Further Reading

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      export interface ServiceMethods<
        Result = any,
        Data = Partial<Result>,
        ServiceParams = Params,
        PatchData = Partial<Data>
      Severity: Major
      Found in packages/feathers/src/declarations.ts and 3 other locations - About 55 mins to fix
      packages/feathers/src/declarations.ts on lines 96..115
      packages/feathers/src/declarations.ts on lines 121..126
      packages/feathers/src/declarations.ts on lines 131..136

      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 33.

      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

      Further Reading

      Function _find has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        async _find(params: ServiceParams = {} as ServiceParams): Promise<Paginated<Result> | Result[]> {
          const { filters, paginate } = this.filterQuery(params)
          const { name, id } = this.getOptions(params)
          const builder = params.knex ? params.knex.clone() : this.createQuery(params)
          const countBuilder = builder.clone().clearSelect().clearOrder().count(`${name}.${id} as total`)
      Severity: Minor
      Found in packages/knex/src/adapter.ts - About 45 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

      Function oauth has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        (settings: Partial<OauthSetupSettings> = {}) =>
        (app: Application) => {
          const authService = app.defaultAuthentication ? app.defaultAuthentication(settings.authService) : null
      
          if (!authService) {
      Severity: Minor
      Found in packages/authentication-oauth/src/index.ts - About 45 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

      Function errorHandler has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
      Open

      export const errorHandler = () => async (ctx: FeathersKoaContext, next: () => Promise<any>) => {
        try {
          await next()
      
          if (ctx.body === undefined) {
      Severity: Minor
      Found in packages/koa/src/handlers.ts - About 35 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

      Severity
      Category
      Status
      Source
      Language