enclose-io/compiler

View on GitHub
lts/lib/internal/bootstrap/pre_execution.js

Summary

Maintainability
F
1 wk
Test Coverage

File pre_execution.js has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

const {
  Map,
  ObjectDefineProperty,
Severity: Minor
Found in lts/lib/internal/bootstrap/pre_execution.js - About 4 hrs to fix

    Function initializeDeprecations has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function initializeDeprecations() {
      const { deprecate } = require('internal/util');
      const pendingDeprecation = getOptionValue('--pending-deprecation');
    
      // DEP0103: access to `process.binding('util').isX` type checkers
    Severity: Major
    Found in lts/lib/internal/bootstrap/pre_execution.js - About 2 hrs to fix

      Function initializePolicy has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function initializePolicy() {
        const experimentalPolicy = getOptionValue('--experimental-policy');
        if (experimentalPolicy) {
          process.emitWarning('Policies are experimental.',
                              'ExperimentalWarning');
      Severity: Minor
      Found in lts/lib/internal/bootstrap/pre_execution.js - 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 initializePolicy has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function initializePolicy() {
        const experimentalPolicy = getOptionValue('--experimental-policy');
        if (experimentalPolicy) {
          process.emitWarning('Policies are experimental.',
                              'ExperimentalWarning');
      Severity: Minor
      Found in lts/lib/internal/bootstrap/pre_execution.js - About 1 hr to fix

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

        function prepareMainThreadExecution(expandArgv1 = false) {
          // Patch the process object with legacy properties and normalizations
          patchProcessObject(expandArgv1);
          setupTraceCategoryState();
          setupInspectorHooks();
        Severity: Minor
        Found in lts/lib/internal/bootstrap/pre_execution.js - About 1 hr to fix

          Function patchProcessObject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function patchProcessObject(expandArgv1) {
            const {
              patchProcessObject: patchProcessObjectNative
            } = internalBinding('process_methods');
          
          
          Severity: Minor
          Found in lts/lib/internal/bootstrap/pre_execution.js - About 1 hr to fix

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

            function initializePolicy() {
              const experimentalPolicy = getOptionValue('--experimental-policy');
              if (experimentalPolicy) {
                process.emitWarning('Policies are experimental.',
                                    'ExperimentalWarning');
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 2 days to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 348..395

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

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

            function initializeDeprecations() {
              const { deprecate } = require('internal/util');
              const pendingDeprecation = getOptionValue('--pending-deprecation');
            
              // DEP0103: access to `process.binding('util').isX` type checkers
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 2 days to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 233..318

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

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

            function prepareMainThreadExecution(expandArgv1 = false) {
              // Patch the process object with legacy properties and normalizations
              patchProcessObject(expandArgv1);
              setupTraceCategoryState();
              setupInspectorHooks();
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 1 day to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 17..76

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

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

            function setupChildProcessIpcChannel() {
              if (process.env.NODE_CHANNEL_FD) {
                const assert = require('internal/assert');
            
                const fd = parseInt(process.env.NODE_CHANNEL_FD, 10);
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 4 hrs to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 320..337

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

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

            function setupCoverageHooks(dir) {
              const cwd = require('internal/process/execution').tryGetCwd();
              const { resolve } = require('path');
              const coverageDirectory = resolve(cwd, dir);
              const { sourceMapCacheToObject } =
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 4 hrs to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 141..158

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

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

            module.exports = {
              patchProcessObject,
              setupCoverageHooks,
              setupWarningHandler,
              setupDebugEnv,
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 3 other locations - About 2 hrs to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 450..465
            current/lib/internal/worker/io.js on lines 276..291
            lts/lib/internal/worker/io.js on lines 255..270

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

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

            function initializeHeapSnapshotSignalHandlers() {
              const signal = getOptionValue('--heapsnapshot-signal');
            
              if (!signal)
                return;
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 1 hr to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 195..207

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

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

            function initializeClusterIPC() {
              if (process.argv[1] && process.env.NODE_UNIQUE_ID) {
                const cluster = require('cluster');
                cluster._setupWorker();
                // Make sure it's not accidentally inherited by child processes.
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 1 hr to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 339..346

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

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

            function addReadOnlyProcessAlias(name, option, enumerable = true) {
              const value = getOptionValue(option);
              if (value) {
                ObjectDefineProperty(process, name, {
                  writable: false,
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 1 hr to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 117..127

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

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

            function setupDebugEnv() {
              require('internal/util/debuglog').initializeDebugEnv(process.env.NODE_DEBUG);
              if (getOptionValue('--expose-internals')) {
                require('internal/bootstrap/loaders').NativeModule.exposeInternals();
              }
            Severity: Major
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 1 hr to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 181..186

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

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

            function setupWarningHandler() {
              const {
                onWarning
              } = require('internal/process/warning');
              if (!getOptionValue('--no-warnings') &&
            Severity: Minor
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 55 mins to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 129..137

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

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

            function setupInspectorHooks() {
              // If Debugger.setAsyncCallStackDepth is sent during bootstrap,
              // we cannot immediately call into JS to enable the hooks, which could
              // interrupt the JS execution of bootstrap. So instead we save the
              // notification in the inspector agent if it's sent in the middle of
            Severity: Minor
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 50 mins to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 215..228

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

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

            function initializeCJSLoader() {
              const CJSLoader = require('internal/modules/cjs/loader');
              CJSLoader.Module._initPaths();
              // TODO(joyeecheung): deprecate this in favor of a proper hook?
              CJSLoader.Module.runMain =
            Severity: Minor
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 50 mins to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 404..410

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

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

            function loadPreloadModules() {
              // For user code, we preload modules if `-r` is passed
              const preloadModules = getOptionValue('--require');
              if (preloadModules && preloadModules.length > 0) {
                const {
            Severity: Minor
            Found in lts/lib/internal/bootstrap/pre_execution.js and 1 other location - About 40 mins to fix
            current/lib/internal/bootstrap/pre_execution.js on lines 437..448

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

            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