enclose-io/compiler

View on GitHub
lts/lib/internal/source_map/source_map_cache.js

Summary

Maintainability
F
1 wk
Test Coverage

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

function maybeCacheSourceMap(filename, content, cjsModuleInstance) {
  if (experimentalSourceMaps === undefined) {
    experimentalSourceMaps = getOptionValue('--enable-source-maps');
  }
  if (!(process.env.NODE_V8_COVERAGE || experimentalSourceMaps)) return;
Severity: Minor
Found in lts/lib/internal/source_map/source_map_cache.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 maybeCacheSourceMap has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function maybeCacheSourceMap(filename, content, cjsModuleInstance) {
  if (experimentalSourceMaps === undefined) {
    experimentalSourceMaps = getOptionValue('--enable-source-maps');
  }
  if (!(process.env.NODE_V8_COVERAGE || experimentalSourceMaps)) return;
Severity: Minor
Found in lts/lib/internal/source_map/source_map_cache.js - About 1 hr to fix

    Function findSourceMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    function findSourceMap(uri, error) {
      if (!Module) Module = require('internal/modules/cjs/loader').Module;
      if (!SourceMap) {
        SourceMap = require('internal/source_map/source_map').SourceMap;
      }
    Severity: Minor
    Found in lts/lib/internal/source_map/source_map_cache.js - 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 sourceMapFromDataUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    function sourceMapFromDataUrl(basePath, url) {
      const [format, data] = url.split(',');
      const splitFormat = format.split(';');
      const contentType = splitFormat[0];
      const base64 = splitFormat[splitFormat.length - 1] === 'base64';
    Severity: Minor
    Found in lts/lib/internal/source_map/source_map_cache.js - 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

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

    function maybeCacheSourceMap(filename, content, cjsModuleInstance) {
      if (experimentalSourceMaps === undefined) {
        experimentalSourceMaps = getOptionValue('--enable-source-maps');
      }
      if (!(process.env.NODE_V8_COVERAGE || experimentalSourceMaps)) return;
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 1 day to fix
    current/lib/internal/source_map/source_map_cache.js on lines 45..83

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

    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 findSourceMap(uri, error) {
      if (!Module) Module = require('internal/modules/cjs/loader').Module;
      if (!SourceMap) {
        SourceMap = require('internal/source_map/source_map').SourceMap;
      }
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 1 day to fix
    current/lib/internal/source_map/source_map_cache.js on lines 229..249

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

    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 sourceMapFromDataUrl(basePath, url) {
      const [format, data] = url.split(',');
      const splitFormat = format.split(';');
      const contentType = splitFormat[0];
      const base64 = splitFormat[splitFormat.length - 1] === 'base64';
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 1 day to fix
    current/lib/internal/source_map/source_map_cache.js on lines 128..147

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

    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 appendCJSCache(obj) {
      if (!Module) return;
      const cjsModuleCache = ObjectGetValueSafe(Module, '_cache');
      const cjsModules = ObjectKeys(cjsModuleCache);
      for (let i = 0; i < cjsModules.length; i++) {
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 6 hrs to fix
    current/lib/internal/source_map/source_map_cache.js on lines 206..223

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

    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

    function sourcesToAbsolute(base, data) {
      data.sources = data.sources.map((source) => {
        source = (data.sourceRoot || '') + source;
        if (!/^[\\/]/.test(source[0])) {
          source = resolve(base, source);
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 5 hrs to fix
    current/lib/internal/source_map/source_map_cache.js on lines 152..165

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

    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

    function sourceMapCacheToObject() {
      const obj = ObjectCreate(null);
    
      const it = MapPrototypeEntries(esmSourceMapCache);
      let entry;
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 5 hrs to fix
    current/lib/internal/source_map/source_map_cache.js on lines 182..199

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

    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 dataFromUrl(basePath, sourceMappingURL) {
      try {
        const url = new URL(sourceMappingURL);
        switch (url.protocol) {
          case 'data:':
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 4 hrs to fix
    current/lib/internal/source_map/source_map_cache.js on lines 85..101

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

    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 sourceMapFromFile(sourceMapFile) {
      try {
        const content = fs.readFileSync(sourceMapFile, 'utf8');
        const data = JSONParse(content);
        return sourcesToAbsolute(dirname(sourceMapFile), data);
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 2 hrs to fix
    current/lib/internal/source_map/source_map_cache.js on lines 115..124

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

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

    const {
      JSONParse,
      ObjectCreate,
      ObjectKeys,
      ObjectGetOwnPropertyDescriptor,
    Severity: Major
    Found in lts/lib/internal/source_map/source_map_cache.js and 9 other locations - About 1 hr to fix
    current/lib/internal/http2/core.js on lines 215..226
    current/lib/internal/source_map/source_map_cache.js on lines 3..14
    current/lib/internal/event_target.js on lines 3..14
    current/lib/internal/worker.js on lines 33..44
    current/lib/readline.js on lines 30..41
    current/lib/util.js on lines 24..35
    lts/lib/internal/worker.js on lines 33..44
    lts/lib/readline.js on lines 30..41
    lts/lib/util.js on lines 24..35

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

    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 rekeySourceMap(cjsModuleInstance, newInstance) {
      const sourceMap = cjsSourceMapCache.get(cjsModuleInstance);
      if (sourceMap) {
        cjsSourceMapCache.set(newInstance, sourceMap);
      }
    Severity: Minor
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 55 mins to fix
    current/lib/internal/source_map/source_map_cache.js on lines 168..173

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

    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 lineLengths(content) {
      // We purposefully keep \r as part of the line-length calculation, in
      // cases where there is a \r\n separator, so that this can be taken into
      // account in coverage calculations.
      return content.split(/\n|\u2028|\u2029/).map((line) => {
    Severity: Minor
    Found in lts/lib/internal/source_map/source_map_cache.js and 1 other location - About 40 mins to fix
    current/lib/internal/source_map/source_map_cache.js on lines 106..113

    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