han-feng/modular

View on GitHub

Showing 190 of 190 total issues

Function init has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  private init() {
    if (this.inited) {
      // 防止初始化两次
      this.log(new LogInfo('E00', 'error'))
      return
Severity: Minor
Found in src/Modular.ts - About 5 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 loadDepens has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  private loadDepens(
    module: ModuleConfig,
    modulesLoader: ModulesLoader,
    nameMapping: { [index: string]: ModuleConfig },
    cache: { [index: string]: ModuleConfig } = {}
Severity: Minor
Found in src/Modular.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 init has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private init() {
    if (this.inited) {
      // 防止初始化两次
      this.log(new LogInfo('E00', 'error'))
      return
Severity: Major
Found in src/Modular.ts - About 2 hrs to fix

    Function loadDepens has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private loadDepens(
        module: ModuleConfig,
        modulesLoader: ModulesLoader,
        nameMapping: { [index: string]: ModuleConfig },
        cache: { [index: string]: ModuleConfig } = {}
    Severity: Minor
    Found in src/Modular.ts - About 1 hr to fix

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

        getExtension(name: string) {
          const point = this.getExtensionPoint(name)
          if (point !== null) {
            return point.getExtension()
          }
      Severity: Major
      Found in src/Modular.ts and 1 other location - About 1 hr to fix
      src/Modular.ts on lines 98..104

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

      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

        getExtensions(name: string) {
          const point = this.getExtensionPoint(name)
          if (point !== null) {
            return point.getExtensions()
          }
      Severity: Major
      Found in src/Modular.ts and 1 other location - About 1 hr to fix
      src/Modular.ts on lines 86..92

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

      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

      Avoid deeply nested control flow statements.
      Open

                  if (points[name].type === Type.Multiple && Array.isArray(ext[name])) {
                    points[name].addExtension(module.name, ...ext[name])
                  } else {
                    points[name].addExtension(module.name, ext[name])
                  }
      Severity: Major
      Found in src/Modular.ts - About 45 mins to fix

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

          private preprocess() {
            if (!this.processed) {
              let extension: any = null
              let extensions = this.extensions
              if (extensions && extensions.length && extensions.length > 0) {
        Severity: Minor
        Found in src/ExtensionPoint.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

        Avoid too many return statements within this function.
        Open

                  return false
        Severity: Major
        Found in src/Modular.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return true
          Severity: Major
          Found in src/Modular.ts - About 30 mins to fix

            Missing semicolon
            Open

            const logger = Logger.get('modular.core.ExtensionPoint')
            Severity: Minor
            Found in src/ExtensionPoint.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Missing semicolon
            Open

              private readonly extensions: any[] = []
            Severity: Minor
            Found in src/ExtensionPoint.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Missing semicolon
            Open

              private extension: any = null
            Severity: Minor
            Found in src/ExtensionPoint.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Missing semicolon
            Open

                        extension = extensions[0]
            Severity: Minor
            Found in src/ExtensionPoint.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Interpolation will only work for template strings.
            Open

                E03: template('“${m1.name}”依赖的模块“${m2}”解析失败'),
            Severity: Minor
            Found in src/LogInfo.ts by tslint

            Rule: no-invalid-template-strings

            Warns on use of ${ in non-template strings.

            Rationale

            Interpolation will only work for template strings.

            Config

            Not configurable.

            Examples
            "no-invalid-template-strings": true

            For more information see this page.

            Missing semicolon
            Open

                this.application = options.application || { name: 'Application' }
            Severity: Minor
            Found in src/Modular.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Missing semicolon
            Open

                logger.error(info)
            Severity: Minor
            Found in src/Modular.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Missing semicolon
            Open

                return this.extension
            Severity: Minor
            Found in src/ExtensionPoint.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Interpolation will only work for template strings.
            Open

                E05: template('模块“${m.name}”声明了重复的 extensionPoint “${ep}”'),
            Severity: Minor
            Found in src/LogInfo.ts by tslint

            Rule: no-invalid-template-strings

            Warns on use of ${ in non-template strings.

            Rationale

            Interpolation will only work for template strings.

            Config

            Not configurable.

            Examples
            "no-invalid-template-strings": true

            For more information see this page.

            Missing semicolon
            Open

                return `[${this.code}] ${this.getMessage()}`
            Severity: Minor
            Found in src/LogInfo.ts by tslint

            Rule: semicolon

            Enforces consistent semicolon usage at the end of every statement.

            Notes
            • Has Fix

            Config

            One of the following arguments must be provided:

            • "always" enforces semicolons at the end of every statement.
            • "never" disallows semicolons at the end of every statement except for when they are necessary.

            The following arguments may be optionally provided:

            • "ignore-interfaces" skips checking semicolons at the end of interface members.
            • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
            • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
            Examples
            "semicolon": true,always
            "semicolon": true,never
            "semicolon": true,always,ignore-interfaces
            "semicolon": true,always,ignore-bound-class-methods
            Schema
            {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "always",
                    "never"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ignore-interfaces"
                  ]
                }
              ],
              "additionalItems": false
            }

            For more information see this page.

            Severity
            Category
            Status
            Source
            Language