iniquitybbs/iniquity

View on GitHub
packages/core/src/index.ts

Summary

Maintainability
F
5 days
Test Coverage

File index.ts has 867 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Iniquity Core
 * @module Core
 * @summary This is the Iniquity core bbs library. It's the foundation of any Iniquity application.
 * @example
Severity: Major
Found in packages/core/src/index.ts - About 2 days to fix

    Function color has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    String.prototype.color = function (color: string): string {
        switch (color) {
            // 16 colors...
            case "black":
                return "\u001b[30m" + this
    Severity: Major
    Found in packages/core/src/index.ts - About 2 hrs to fix

      Function render has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          render(options?: IQArtworkRenderOptions): IQArtworkRenderFunctions {
              if (options?.clearScreenBefore === true) console.putmsg("@POFF@@CLS@@PON@".color("reset"))
      
              const basepath = options?.basepath ?? this.basepath
              const filename = options?.filename ?? this.filename ?? new Error("I need to know what file to display!")
      Severity: Minor
      Found in packages/core/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 render has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          render(options?: IQArtworkRenderOptions): IQArtworkRenderFunctions {
              if (options?.clearScreenBefore === true) console.putmsg("@POFF@@CLS@@PON@".color("reset"))
      
              const basepath = options?.basepath ?? this.basepath
              const filename = options?.filename ?? this.filename ?? new Error("I need to know what file to display!")
      Severity: Major
      Found in packages/core/src/index.ts - About 2 hrs to fix

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

            public prompt(options?: IQMenuPromptOptions | string): IQMenuPromptFunctions {
                if (!this.commands) throw new Error("No commands appear to be configured for this menu.")
        
                const commands = Object.keys(this.commands)
                    .filter((cmdkey) => cmdkey != "default")
        Severity: Minor
        Found in packages/core/src/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 IQReactor has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function IQReactor(dataObj: any): IQReactorOptions {
            const signals = {}
        
            observeData(dataObj)
        
        
        Severity: Minor
        Found in packages/core/src/index.ts - About 1 hr to fix

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

          export function IQReactor(dataObj: any): IQReactorOptions {
              const signals = {}
          
              observeData(dataObj)
          
          
          Severity: Minor
          Found in packages/core/src/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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public render(module: Function, options?: IQMenuLoopOptions): void {
                  let count = 0
                  let cache: IQMenuLoopMessageResponse = {}
                  const maxInterval = options?.maxInterval ?? 10000000
          
          
          Severity: Minor
          Found in packages/core/src/index.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

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

              constructor(options: IQMenuOptions) {
                  if (options.name) this.name = options.name
                  if (options.description) this.description = options.name
                  if (options.commands) this.commands = options.commands
                  for (const [cmdkey, command] of Object.entries(this.commands!)) if (cmdkey != "default") this.cmdkeys += cmdkey
          Severity: Minor
          Found in packages/core/src/index.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

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

                  return {
                      pause(options?: IQPauseOptions): void {
                          pause(options)
                      },
                      wait(options?: IQWaitOptions): void {
          Severity: Major
          Found in packages/core/src/index.ts and 2 other locations - About 2 hrs to fix
          packages/core/src/index.ts on lines 428..438
          packages/core/src/index.ts on lines 1155..1165

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

          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 3 locations. Consider refactoring.
          Open

              return {
                  pause(options?: IQPauseOptions): void {
                      pause(options)
                  },
                  wait(options?: IQWaitOptions): void {
          Severity: Major
          Found in packages/core/src/index.ts and 2 other locations - About 2 hrs to fix
          packages/core/src/index.ts on lines 400..410
          packages/core/src/index.ts on lines 428..438

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

          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 3 locations. Consider refactoring.
          Open

                  return {
                      pause(options?: IQPauseOptions): void {
                          pause(options)
                      },
                      wait(options?: IQWaitOptions): void {
          Severity: Major
          Found in packages/core/src/index.ts and 2 other locations - About 2 hrs to fix
          packages/core/src/index.ts on lines 400..410
          packages/core/src/index.ts on lines 1155..1165

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

          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

              export function ask(question: string, callback?: any): string | undefined {
                  if (!callback) return iq.ask(question)
                  else callback(iq.ask(question))
              }
          Severity: Major
          Found in packages/core/src/index.ts and 1 other location - About 1 hr to fix
          packages/core/src/index.ts on lines 1209..1212

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

          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

          export function ask(question: string, callback?: any): string | undefined {
              if (!callback) return iq.ask(question)
              else callback(iq.ask(question))
          }
          Severity: Major
          Found in packages/core/src/index.ts and 1 other location - About 1 hr to fix
          packages/core/src/index.ts on lines 1265..1268

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

          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

          export interface IBBSSayFunctions {
              /**
               * @param {IQPauseOptions} options
               * {@link IQPauseOptions}
               */
          Severity: Major
          Found in packages/core/src/index.ts and 1 other location - About 1 hr to fix
          packages/core/src/index.ts on lines 283..291

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

          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

          export interface IBBSPrintFunctions {
              /**
               * @param {IQPauseOptions} options
               * @see {@link IQPauseOptions}
               */
          Severity: Major
          Found in packages/core/src/index.ts and 1 other location - About 1 hr to fix
          packages/core/src/index.ts on lines 274..282

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

          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

          There are no issues that match your filters.

          Category
          Status