mindjs/mindjs

View on GitHub
packages/core/src/lib/framework/core.js

Summary

Maintainability
D
1 day
Test Coverage

File core.js has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const { flatten, isFunction, every, get } = require('lodash');

const {
  ReflectiveInjector,
} = require('@mindjs/common/DI');
Severity: Minor
Found in packages/core/src/lib/framework/core.js - About 3 hrs to fix

    Function initModuleDI has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static async initModuleDI(moduleDI, platform = undefined) {
        if (!(moduleDI && moduleDI.module)) {
          return;
        }
    
    
    Severity: Minor
    Found in packages/core/src/lib/framework/core.js - About 2 hrs to fix

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

        static async initRoutingModulesDI(moduleDI) {
          const { rootInjector, injector: parentModuleInjector, module: parentModule } = moduleDI;
      
          const routingModules = await Mind.extractRoutingModules({
            rootInjector,
      Severity: Minor
      Found in packages/core/src/lib/framework/core.js - About 1 hr to fix

        Function initAndStart has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async initAndStart() {
            if (!this.rootModuleDI || this.isAppMindInitiated) {
              return this;
            }
        
        
        Severity: Minor
        Found in packages/core/src/lib/framework/core.js - About 1 hr to fix

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

            static async invokeInitializers(rootDI = {}, platform) {
              const { rootInjector, injector } = rootDI;
          
              if (!rootInjector) {
                throw new Error(('injector was not provided'));
          Severity: Minor
          Found in packages/core/src/lib/framework/core.js - About 1 hr to fix

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

              static async initModuleDI(moduleDI, platform = undefined) {
                if (!(moduleDI && moduleDI.module)) {
                  return;
                }
            
            
            Severity: Minor
            Found in packages/core/src/lib/framework/core.js - 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

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

                try {
                  await this.invokeInitializers();
                  this.appServerMindInitializersInvoked = true;
                } catch (e) {
                  console.error(e);
            Severity: Major
            Found in packages/core/src/lib/framework/core.js and 2 other locations - About 1 hr to fix
            packages/core/src/lib/framework/core.js on lines 425..431
            packages/core/src/lib/framework/core.js on lines 433..439

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

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

                try {
                  await this.initRouting();
                  this.appRoutingMindInitiated = true;
                } catch (e) {
                  console.error(e);
            Severity: Major
            Found in packages/core/src/lib/framework/core.js and 2 other locations - About 1 hr to fix
            packages/core/src/lib/framework/core.js on lines 417..423
            packages/core/src/lib/framework/core.js on lines 433..439

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

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

                try {
                  await this.startServer();
                  this.appServerMindStarted = true;
                } catch (e) {
                  console.error(e);
            Severity: Major
            Found in packages/core/src/lib/framework/core.js and 2 other locations - About 1 hr to fix
            packages/core/src/lib/framework/core.js on lines 417..423
            packages/core/src/lib/framework/core.js on lines 425..431

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

            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

              async startServer() {
                if (!this.rootModuleDI) {
                  return this;
                }
                await Mind.startServer(this.rootModuleDI);
            Severity: Minor
            Found in packages/core/src/lib/framework/core.js and 1 other location - About 40 mins to fix
            packages/core/src/lib/framework/core.js on lines 388..394

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

            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

              async initRouting() {
                if (!this.rootModuleDI) {
                  return this;
                }
                await Mind.initRouting(this.rootModuleDI);
            Severity: Minor
            Found in packages/core/src/lib/framework/core.js and 1 other location - About 40 mins to fix
            packages/core/src/lib/framework/core.js on lines 400..406

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

            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

                const appMiddleware = toArray(injectSync(rootInjector, APP_MIDDLEWARE, [])).filter(m => {
                  return !platformMiddleware.includes(m);
                });
            Severity: Minor
            Found in packages/core/src/lib/framework/core.js and 1 other location - About 30 mins to fix
            packages/core/src/lib/framework/core.js on lines 150..152

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

            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

                const appInitializers = toArray(injectSync(rootInjector, APP_INITIALIZER, [])).filter(i => {
                  return !platformInitializers.includes(i);
                });
            Severity: Minor
            Found in packages/core/src/lib/framework/core.js and 1 other location - About 30 mins to fix
            packages/core/src/lib/framework/core.js on lines 158..160

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

            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