KnodesCommunity/typedoc-plugins

View on GitHub

Showing 21 of 27 total issues

File page-tree-builder.spec.ts has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isString, noop, omit } from 'lodash';
import { Class } from 'type-fest';
import { DeclarationReflection, LogLevel, ProjectReflection, Reflection, ReflectionKind, SourceReference, normalizePath } from 'typedoc';

import { resolve } from '@knodes/typedoc-pluginutils/path';

    File monorepo.spec.ts has 308 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { resolve } from '@knodes/typedoc-pluginutils/path';
    
    import { describeDocsFile, formatHtml, getBreadcrumb, runPluginBeforeAll } from '#plugintestbed';
    
    import { elementMatcher, menuItemMatcher } from '../helpers';
    Severity: Minor
    Found in packages/plugin-pages/__tests__/integration/monorepo.spec.ts - About 3 hrs to fix

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

      const spawn = ( cmd, args, opts = {} ) => new Promise( ( res, rej ) => {
          const { stdio } = opts;
          if( !opts.stdio ){
              opts.stdio = [ null, process.stdout, process.stderr ];
          }
      Severity: Minor
      Found in tools/utils.js - 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 mockPlugin has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const mockPlugin = <T extends ABasePlugin = ABasePlugin>( props: Partial<MockPlugin<T>> = {} ): MockPlugin<T> => {
          const mockLogger = {
              makeChildLogger: jest.fn(),
              error: jest.fn().mockImplementation( v => assert.fail( `Unexpected error log: ${typeof v === 'function' ? v() : v}` ) ),
              warn: jest.fn().mockImplementation( v => assert.fail( `Unexpected warn log: ${typeof v === 'function' ? v() : v}` ) ),
      Severity: Minor
      Found in packages/plugintestbed/src/mock-plugin.ts - About 1 hr to fix

        Function setupCaptureEvent has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const setupCaptureEvent = <T extends EventDispatcher>( cls: Class<T>, eventName: string ) => {
            let listenerToTest: CallableFunction[] = [];
            let baseOn: EventDispatcher['on'];
            function registerEvent( eventMap: EventMap ): T;
            function registerEvent( eventMap: EventMap, callback?: EventCallback ): T;
        Severity: Minor
        Found in packages/plugintestbed/src/capture-event.ts - About 1 hr to fix

          Function _onRendererBeginPageAlterModel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private _onRendererBeginPageAlterModel( pageEvent: PageEvent<any> ) {
                  if( pageEvent.model instanceof ANodeReflection ){
                      const newModel = this._nodeDeclarationMappingCache.get( pageEvent.model );
                      assert( newModel );
                      this._addRestore( () => newModel.children, v => newModel.children = v );
          Severity: Minor
          Found in packages/plugin-pages/src/output/theme/default-pages-renderer.tsx - 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 _onRendererBeginPageAlterModel has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private _onRendererBeginPageAlterModel( pageEvent: PageEvent<any> ) {
                  if( pageEvent.model instanceof ANodeReflection ){
                      const newModel = this._nodeDeclarationMappingCache.get( pageEvent.model );
                      assert( newModel );
                      this._addRestore( () => newModel.children, v => newModel.children = v );
          Severity: Minor
          Found in packages/plugin-pages/src/output/theme/default-pages-renderer.tsx - About 1 hr to fix

            Function spawn has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const spawn = ( cmd, args, opts = {} ) => new Promise( ( res, rej ) => {
                const { stdio } = opts;
                if( !opts.stdio ){
                    opts.stdio = [ null, process.stdout, process.stderr ];
                }
            Severity: Minor
            Found in tools/utils.js - About 1 hr to fix

              Function buildPagesTree has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public buildPagesTree( project: ProjectReflection, options: IPluginOptions ): MenuReflection {
                      const rootMenu = new MenuReflection( 'ROOT', project, undefined, '' );
                      if( !options.pages || options.pages.length === 0 ){
                          return rootMenu;
                      } else {
              Severity: Minor
              Found in packages/plugin-pages/src/converter/page-tree/page-tree-builder.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 _mapNodeToReflection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private _mapNodeToReflection( node: PageNode, parent: ANodeReflection.Parent, io: IIOPath ): NodeReflection[] {
                      const childrenIO: IIOPath = isModuleRoot( node ) ? { ...io } : {
                          ...io,
                          input: join( io.input, getDir( node, 'source' ) ),
                          output: join( io.output, getDir( node, 'output' ) ),
              Severity: Minor
              Found in packages/plugin-pages/src/converter/page-tree/page-tree-builder.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 _mapNodeToReflection has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private _mapNodeToReflection( node: PageNode, parent: ANodeReflection.Parent, io: IIOPath ): NodeReflection[] {
                      const childrenIO: IIOPath = isModuleRoot( node ) ? { ...io } : {
                          ...io,
                          input: join( io.input, getDir( node, 'source' ) ),
                          output: join( io.output, getDir( node, 'output' ) ),
              Severity: Minor
              Found in packages/plugin-pages/src/converter/page-tree/page-tree-builder.ts - About 1 hr to fix

                Function _replaceCodeBlock has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private _replaceCodeBlock( match: MarkdownReplacer.Match, sourceHint: MarkdownReplacer.SourceHint ) {
                        // Avoid recursion in code blocks
                        if( this._currentPageMemo.currentReflection instanceof DeclarationReflection && this._currentPageMemo.currentReflection.kind === CODEBLOCK_KIND ){
                            return undefined;
                        }
                Severity: Minor
                Found in packages/plugin-code-blocks/src/output/markdown-code-blocks.ts - About 1 hr to fix

                  Function setupMockPageMemo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const setupMockPageMemo = () => {
                      const capture = setupCaptureEvent( Renderer, PageEvent.BEGIN );
                      return {
                          captureEventRegistration: capture.captureEventRegistration,
                          setCurrentPage: <T extends Reflection>(
                  Severity: Minor
                  Found in packages/plugintestbed/src/mock-page-memo.ts - About 1 hr to fix

                    Function _getNodeReflection has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private _getNodeReflection( node: PageNode, parent: ANodeReflection.Parent, io: IIOPath ){
                            const { module, parent: actualParent } = this._getNodeParent( node, parent );
                            if( node.source ){
                                const nodePath = join( io.input, node.source );
                                const sourceFilePath = miscUtils.catchWrap(
                    Severity: Minor
                    Found in packages/plugin-pages/src/converter/page-tree/page-tree-builder.ts - About 1 hr to fix

                      Function mockPlugin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const mockPlugin = <T extends ABasePlugin = ABasePlugin>( props: Partial<MockPlugin<T>> = {} ): MockPlugin<T> => {
                          const mockLogger = {
                              makeChildLogger: jest.fn(),
                              error: jest.fn().mockImplementation( v => assert.fail( `Unexpected error log: ${typeof v === 'function' ? v() : v}` ) ),
                              warn: jest.fn().mockImplementation( v => assert.fail( `Unexpected warn log: ${typeof v === 'function' ? v() : v}` ) ),
                      Severity: Minor
                      Found in packages/plugintestbed/src/mock-plugin.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 buildOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const buildOptions = ( plugin: PagesPlugin ) => OptionGroup.factory<IPluginOptions>( plugin )
                          .add( 'enablePageLinks', {
                              help: 'Whether or not @page and @pagelink tags should be parsed.',
                              type: ParameterType.Boolean,
                              defaultValue: true,
                      Severity: Minor
                      Found in packages/plugin-pages/src/options/build.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 wrapPageError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const wrapPageError = ( path: string[], index: number ) => ( err: any ) => {
                          if( err instanceof AssertionError ){
                              const pathStr = path.length > 0 ? ` in ${path.map( p => JSON.stringify( p ) ).join( ' ⇒ ' )}` : '';
                              return new Error( `Invalid page${pathStr} @ index ${index}: ${err.message ?? err}`, { cause: err } );
                          } else {
                      Severity: Minor
                      Found in packages/plugin-pages/src/options/build.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

                      Function _onRendererBeginPageAlterNavigation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _onRendererBeginPageAlterNavigation( pageEvent: PageEvent<any> ) {
                              this._addRestore( () => pageEvent.project.children, prev => pageEvent.project.children = prev );
                              const modelModule = getReflectionModule( pageEvent.model );
                              const projectPages = this._modulesPages.find( p => p.module === pageEvent.project );
                              pageEvent.project.children = [
                      Severity: Minor
                      Found in packages/plugin-pages/src/output/theme/default-pages-renderer.tsx - 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

                      Function _setValueFromObject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private _setValueFromObject( value: OptionGroupSetValue<TDeclarations> ){
                              const valKeys = Object.keys( value );
                              const optKeys = Object.keys( this._options );
                              for( const unknownOption of difference( valKeys, optKeys ) ){
                                  this.plugin.logger.warn( `Unknown option "${unknownOption}". Did you mean "${closest( unknownOption, optKeys )}" ?` );
                      Severity: Minor
                      Found in packages/pluginutils/src/options/option-group.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

                      Function matchReflection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const matchReflection = <T extends Reflection>( proto: Class<T>, sample: Partial<T> ) => expect.toSatisfy( v => {
                          expect( v ).toBeInstanceOf( proto );
                          const s = sample as any;
                          if( 'sourceFilePath' in s && isString( s.sourceFilePath ) ){
                              s.sourceFilePath = normalizePath( resolve( s.sourceFilePath ) );
                      Severity: Minor
                      Found in packages/plugin-pages/src/converter/page-tree/page-tree-builder.spec.ts - About 25 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