KnodesCommunity/typedoc-plugins

View on GitHub

Showing 27 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

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

                      module.exports = {
                          ...base,
                          projects: [
                              base.projects[0],
                              {
                      Severity: Major
                      Found in tools/proto/jest.config.js and 3 other locations - About 50 mins to fix
                      packages/plugin-code-blocks/jest.config.js on lines 3..12
                      packages/plugin-pages/jest.config.js on lines 3..12
                      packages/plugintestbed/jest.config.js on lines 3..12

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

                      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

                      module.exports = {
                          ...base,
                          projects: [
                              base.projects[0],
                              {
                      Severity: Major
                      Found in packages/plugin-pages/jest.config.js and 3 other locations - About 50 mins to fix
                      packages/plugin-code-blocks/jest.config.js on lines 3..12
                      packages/plugintestbed/jest.config.js on lines 3..12
                      tools/proto/jest.config.js on lines 3..12

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

                      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

                      module.exports = {
                          ...base,
                          projects: [
                              base.projects[0],
                              {
                      Severity: Major
                      Found in packages/plugin-code-blocks/jest.config.js and 3 other locations - About 50 mins to fix
                      packages/plugin-pages/jest.config.js on lines 3..12
                      packages/plugintestbed/jest.config.js on lines 3..12
                      tools/proto/jest.config.js on lines 3..12

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

                      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

                      module.exports = {
                          ...base,
                          projects: [
                              base.projects[0],
                              {
                      Severity: Major
                      Found in packages/plugintestbed/jest.config.js and 3 other locations - About 50 mins to fix
                      packages/plugin-code-blocks/jest.config.js on lines 3..12
                      packages/plugin-pages/jest.config.js on lines 3..12
                      tools/proto/jest.config.js on lines 3..12

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

                      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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              it( 'should map page to workspace with children with pages in module', () => {
                                  addChildModule( 'SUB' );
                                  const targetModule = addChildModule( 'SUB2' );
                                  setVirtualFs( {
                                      SUB2: {
                      packages/plugin-pages/src/converter/page-tree/page-tree-builder.spec.ts on lines 220..240

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

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

                      Severity
                      Category
                      Status
                      Source
                      Language