dodekeract/symlinker

View on GitHub
symlinker.js

Summary

Maintainability
F
4 days
Test Coverage

Function runQueue has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring.
Open

function runQueue () {
    queueRunning = true;

    console.log('runQueue: starting with ' + queue.length + ' tasks.');

Severity: Minor
Found in symlinker.js - About 1 day 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 runTasks has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

function runTasks (task, options) {
    for (var i = 0; i < task.length; i++) {
        var q = task[i];

        // checking if source folder is valid
Severity: Minor
Found in symlinker.js - About 4 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 runQueue has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function runQueue () {
    queueRunning = true;

    console.log('runQueue: starting with ' + queue.length + ' tasks.');

Severity: Major
Found in symlinker.js - About 3 hrs to fix

    File symlinker.js has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var mkdirp = require('mkdirp');
    
    var path = require('path');
    
    var fs = require('fs');
    Severity: Minor
    Found in symlinker.js - About 3 hrs to fix

      Function open has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function open (options) {
          var rawFile;
          // options:
          // -path
          // -type
      Severity: Major
      Found in symlinker.js - About 2 hrs to fix

        Function runTasks has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function runTasks (task, options) {
            for (var i = 0; i < task.length; i++) {
                var q = task[i];
        
                // checking if source folder is valid
        Severity: Minor
        Found in symlinker.js - About 1 hr to fix

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

          function open (options) {
              var rawFile;
              // options:
              // -path
              // -type
          Severity: Minor
          Found in symlinker.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 basic has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function basic (sourcePath, destinationPath, options, callback) {
              try {
                  if (fs.lstatSync(destinationPath).isSymbolicLink()) {
                      if (!options.recreateSymbolicLinks) {
                          process.nextTick(function () {
          Severity: Minor
          Found in symlinker.js - About 1 hr to fix

            Function basic has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function basic (sourcePath, destinationPath, options, callback) {
                try {
                    if (fs.lstatSync(destinationPath).isSymbolicLink()) {
                        if (!options.recreateSymbolicLinks) {
                            process.nextTick(function () {
            Severity: Minor
            Found in symlinker.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

            Avoid deeply nested control flow statements.
            Open

                            } else if (fileDestinationExisting) {
                                if (!currentTask.options.ignoreExisting) {
                                    console.error('runQueue: error - file already existing', fileDestinationPath);
                                    currentTask.failed = true;
                                    currentTask.callback(new Error('Could not create symbolic link. Source file is invalid.'), null);
            Severity: Major
            Found in symlinker.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (!currentTask.options.recreateSymbolicLinks) { // not allowed to unlink symbolic links
                                      // process queue
                                      console.error('runQueue: error - destination is symlink', fileDestinationPath);
                                      currentTask.failed = true;
                                      currentTask.callback(new Error('Could not create symbolic link. Destination is already a symbolic link.'), null);
              Severity: Major
              Found in symlinker.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (fileSourceStats.isDirectory()) {
                                        fs.symlinkSync(fileSourcePath, fileDestinationPath, 'dir');
                                    } else if (fileSourceStats.isFile()) {
                                        fs.symlinkSync(fileSourcePath, fileDestinationPath, 'file');
                                    } else {
                Severity: Major
                Found in symlinker.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (!options.forceRecreation) {
                                                  console.log("Symbolic link " + outputPath  + " already exists.\nUse -r to force symbolic link recreation.");
                                                  process.exit(1);
                                              } else {
                                                  fs.unlinkSync(outputPath);
                  Severity: Major
                  Found in symlinker.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                    for (var i = 0; i < currentTask.files.length; i++) {
                                        var currentFile = currentTask.files[i];
                    
                                        var fileName = (currentFile.name) ? currentFile.name : currentFile.path;
                    
                    
                    Severity: Major
                    Found in symlinker.js - About 45 mins to fix

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

                                          if (!currentTask.options.ignoreExisting) {
                                              console.error('runQueue: error - file already existing', fileDestinationPath);
                                              currentTask.failed = true;
                                              currentTask.callback(new Error('Could not create symbolic link. Source file is invalid.'), null);
                                              break; // skip task
                      Severity: Minor
                      Found in symlinker.js and 1 other location - About 35 mins to fix
                      symlinker.js on lines 356..361

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

                      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

                                      if (fileSourceValid) {
                                          var fileSourceStats = fs.lstatSync(fileSourcePath);
                      
                                          mkdirp.sync(path.dirname(fileDestinationPath)); // create destination directory
                      
                      
                      Severity: Minor
                      Found in symlinker.js and 1 other location - About 35 mins to fix
                      symlinker.js on lines 316..323

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

                      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

                                          } else if (fileSourceStats.isFile()) {
                                              fs.symlinkSync(fileSourcePath, fileDestinationPath, 'file');
                                          } else {
                                              console.error('runQueue: error - source neither file nor folder', fileSourcePath);
                                              currentTask.failed = true;
                      Severity: Minor
                      Found in symlinker.js and 1 other location - About 35 mins to fix
                      symlinker.js on lines 309..329

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

                      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

                                          } else if (!currentTask.options.ignoreMissingSymbolicLinks) {
                                              console.error('runQueue: error - smbolic link not found', filePath);
                                              currentTask.failed = true;
                                              currentTask.callback(new Error('Could not unlink symbolic link. File not found.'), null);
                                              break; // skip task
                      Severity: Minor
                      Found in symlinker.js and 1 other location - About 35 mins to fix
                      symlinker.js on lines 300..307

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

                      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