denali-js/core

View on GitHub

Showing 38 of 38 total issues

JSONAPISerializer has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

export default abstract class JSONAPISerializer extends Serializer {

  /**
   * The default content type to use for any responses rendered by this serializer.
   *
Severity: Minor
Found in lib/render/json-api.ts - About 3 hrs to fix

    File json-api-test.ts has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* tslint:disable:completed-docs no-empty no-invalid-this member-access */
    import { isArray } from 'lodash';
    import {
      setupUnitTest,
      JSONAPISerializer,
    Severity: Minor
    Found in test/unit/render/json-api-test.ts - About 3 hrs to fix

      Model has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class Model extends DenaliObject {
      
        /**
         * Marks the Model as an abstract base model, so ORM adapters can know not to
         * create tables or other supporting infrastructure.
      Severity: Minor
      Found in lib/data/model.ts - About 2 hrs to fix

        Function run has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async run(argv: any) {
            let files = (<string[] | void>argv.files) || [];
            if (files.length === 0) {
              files.push('test/**/*.js');
            } else {
        Severity: Major
        Found in commands/test.ts - About 2 hrs to fix

          Function baseMiddleware has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function baseMiddleware(router: Router, application: Application): void {
          
            let config = application.config;
          
            /**
          Severity: Major
          Found in config/middleware.ts - About 2 hrs to fix

            Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              async run(argv: any) {
                let files = (<string[] | void>argv.files) || [];
                if (files.length === 0) {
                  files.push('test/**/*.js');
                } else {
            Severity: Minor
            Found in commands/test.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 runTests has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              protected runTests(files: string[], project: Project, outputDir: string, argv: any) {
                let avaPath = path.join(process.cwd(), 'node_modules', '.bin', 'ava');
                files = files.map((pattern) => path.join(outputDir, pattern));
                let args = files.concat([ '--concurrency', argv.concurrency ]);
                if (argv.debug) {
            Severity: Minor
            Found in commands/test.ts - About 1 hr to fix

              Function _augmentWithSchemaAccessors has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private static _augmentWithSchemaAccessors() {
                  if ((<any>this.prototype)[augmentedWithAccessors]) {
                    return;
                  }
                  (<any>this.prototype)[augmentedWithAccessors] = true;
              Severity: Minor
              Found in lib/data/model.ts - About 1 hr to fix

                Function baseMiddleware has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function baseMiddleware(router: Router, application: Application): void {
                
                  let config = application.config;
                
                  /**
                Severity: Minor
                Found in config/middleware.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 lookup has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  lookup<T>(specifier: string, options: { raw?: true, loose?: boolean } = {}): T | false {
                    // Raw lookups skip caching and singleton behavior
                    if (options.raw) {
                       let entry = this.lookupRaw<T>(specifier);
                       if (entry === false && !options.loose) {
                Severity: Minor
                Found in lib/metal/container.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 run has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async run(argv: any) {
                    let knex = tryRequire('knex');
                    if (!knex) {
                      await spinner.start('Installing knex (required for migrations)');
                      let yarnExists = await commandExists('yarn');
                Severity: Minor
                Found in commands/migrate.ts - About 1 hr to fix

                  Function run has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async run(argv: any) {
                      debug('running server command');
                      if (argv.production) {
                        argv.skipBuild = true;
                        argv.environment = 'production';
                  Severity: Minor
                  Found in commands/server.ts - About 1 hr to fix

                    Function constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      constructor(options: MockMessageOptions = {}) {
                        super();
                    
                        this.method = options.method || this.method;
                    
                    
                    Severity: Minor
                    Found in lib/test/mock-request.ts - About 1 hr to fix

                      Function resource has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        resource(resourceName: string, options: ResourceOptions = {}): void {
                          let plural = pluralize(resourceName);
                          let collection = `/${ plural }`;
                          let resource = `${ collection }/:id`;
                          let relationship = `${ resource }/relationships/:relation`;
                      Severity: Minor
                      Found in lib/runtime/router.ts - About 1 hr to fix

                        Function render has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async render(status: number, body?: any, options?: RenderOptions): Promise<void> {
                            if (typeof status !== 'number') {
                              options = body;
                              body = status;
                              status = 200;
                        Severity: Minor
                        Found in lib/runtime/action.ts - About 1 hr to fix

                          Function installAddon has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async installAddon(addonName: string) {
                              debug(`attempting to install ${ addonName }`);
                              // Find the package info first to confirm it exists and is a denali addon
                              let pkgManager = await commandExists('yarn') ? 'yarn' : 'npm';
                              debug(`package manager is: ${ pkgManager }`);
                          Severity: Minor
                          Found in commands/install.ts - About 1 hr to fix

                            Function run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              async run(argv: any) {
                                debug('running server command');
                                if (argv.production) {
                                  argv.skipBuild = true;
                                  argv.environment = 'production';
                            Severity: Minor
                            Found in commands/server.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 constructor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              constructor(options: MockMessageOptions = {}) {
                                super();
                            
                                this.method = options.method || this.method;
                            
                            
                            Severity: Minor
                            Found in lib/test/mock-request.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 run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              async run(argv: any) {
                                ui.info(`Loading ${ argv.environment } environment. Type '.help' for details`);
                                let project = new Project({
                                  environment: argv.environment,
                                  printSlowTrees: argv.printSlowTrees
                            Severity: Minor
                            Found in commands/console.ts - About 1 hr to fix

                              Function namespace has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                namespace(namespace: string, fn: (wrapper: RouterDSL) => void): void {
                                  let router = this;
                                  if (namespace.endsWith('/')) {
                                    namespace = namespace.slice(0, namespace.length - 1);
                                  }
                              Severity: Minor
                              Found in lib/runtime/router.ts - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language