adobe/brackets

View on GitHub
src/languageTools/LanguageClient/ServerUtils.js

Summary

Maintainability
F
3 days
Test Coverage

File ServerUtils.js has 337 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2019 - present Adobe. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
Severity: Minor
Found in src/languageTools/LanguageClient/ServerUtils.js - About 4 hrs to fix

    Function _createReaderAndWriteByCommunicationType has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function _createReaderAndWriteByCommunicationType(resp, type) {
            var retval = null;
    
            switch (type) {
                case CommunicationTypes.NodeIPC.type:
    Severity: Major
    Found in src/languageTools/LanguageClient/ServerUtils.js - About 2 hrs to fix

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

          function _startServerAndGetTransports(communication, processArgs, isRuntime) {
              return new Promise(function (resolve, reject) {
                  var serverProcess = null,
                      result = null,
                      protocolTransport = null,
      Severity: Minor
      Found in src/languageTools/LanguageClient/ServerUtils.js - About 2 hrs to fix

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

            function _handleOtherRuntime(serverOptions) {
                function _getArguments(sOptions) {
                    var args = [];
        
                    if (sOptions.options && sOptions.options.execArgv) {
        Severity: Minor
        Found in src/languageTools/LanguageClient/ServerUtils.js - About 1 hr to fix

          Function _handleNodeRuntime has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function _handleNodeRuntime(serverOptions) {
                  function _getArguments(sOptions) {
                      var args = [];
          
                      if (sOptions.args) {
          Severity: Minor
          Found in src/languageTools/LanguageClient/ServerUtils.js - About 1 hr to fix

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

                function addCommunicationArgs(communication, processArgs, isRuntime) {
                    switch (communication) {
                        case CommunicationTypes.NodeIPC.type:
                            {
                                if (isRuntime) {
            Severity: Minor
            Found in src/languageTools/LanguageClient/ServerUtils.js - About 1 hr to fix

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

                              if (sOptions.options.cwd) {
                                  try {
                                      if (fs.lstatSync(sOptions.options.cwd).isDirectory(sOptions.options.cwd)) {
                                          cwd = sOptions.options.cwd;
                                      }
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 1 other location - About 2 hrs to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 289..295

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

              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

                              if (sOptions.options.cwd) {
                                  try {
                                      if (fs.lstatSync(sOptions.options.cwd).isDirectory(sOptions.options.cwd)) {
                                          cwd = sOptions.options.cwd;
                                      }
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 1 other location - About 2 hrs to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 339..345

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

              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

                      var communication = serverOptions.communication || CommunicationTypes.StandardIO.type,
                          args = _getArguments(serverOptions),
                          options = _getOptions(serverOptions),
                          processArgs = {
                              args: args,
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 1 other location - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 311..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 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

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

                      var communication = serverOptions.communication || CommunicationTypes.StandardIO.type,
                          args = _getArguments(serverOptions),
                          options = _getOptions(serverOptions),
                          processArgs = {
                              args: args,
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 1 other location - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 357..364

              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

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

                                      resp.process.stdout.on('data', function (data) {
                                          if (global.LanguageClientInfo.preferences.showServerLogsInConsole) {
                                              console.info('[Server logs @ stdout] "%s"', String(data));
                                          }
                                      });
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 5 other locations - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 111..115
              src/languageTools/LanguageClient/ServerUtils.js on lines 117..121
              src/languageTools/LanguageClient/ServerUtils.js on lines 133..137
              src/languageTools/LanguageClient/ServerUtils.js on lines 150..154
              src/languageTools/LanguageClient/ServerUtils.js on lines 191..195

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

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

                                      resp.process.stderr.on('data', function (data) {
                                          if (global.LanguageClientInfo.preferences.showServerLogsInConsole) {
                                              console.error('[Server logs @ stderr] "%s"', String(data));
                                          }
                                      });
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 5 other locations - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 111..115
              src/languageTools/LanguageClient/ServerUtils.js on lines 117..121
              src/languageTools/LanguageClient/ServerUtils.js on lines 133..137
              src/languageTools/LanguageClient/ServerUtils.js on lines 156..160
              src/languageTools/LanguageClient/ServerUtils.js on lines 191..195

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

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

                                      resp.process.stdout.on('data', function (data) {
                                          if (global.LanguageClientInfo.preferences.showServerLogsInConsole) {
                                              console.info('[Server logs @ stdout] "%s"', String(data));
                                          }
                                      });
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 5 other locations - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 111..115
              src/languageTools/LanguageClient/ServerUtils.js on lines 133..137
              src/languageTools/LanguageClient/ServerUtils.js on lines 150..154
              src/languageTools/LanguageClient/ServerUtils.js on lines 156..160
              src/languageTools/LanguageClient/ServerUtils.js on lines 191..195

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

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

                                      resp.process.stderr.on('data', function (data) {
                                          if (global.LanguageClientInfo.preferences.showServerLogsInConsole) {
                                              console.error('[Server logs @ stderr] "%s"', String(data));
                                          }
                                      });
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 5 other locations - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 111..115
              src/languageTools/LanguageClient/ServerUtils.js on lines 117..121
              src/languageTools/LanguageClient/ServerUtils.js on lines 150..154
              src/languageTools/LanguageClient/ServerUtils.js on lines 156..160
              src/languageTools/LanguageClient/ServerUtils.js on lines 191..195

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

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

                          resp.process.stderr.on('data', function (data) {
                              if (global.LanguageClientInfo.preferences.showServerLogsInConsole) {
                                  console.error('[Server logs @ stderr] "%s"', String(data));
                              }
                          });
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 5 other locations - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 111..115
              src/languageTools/LanguageClient/ServerUtils.js on lines 117..121
              src/languageTools/LanguageClient/ServerUtils.js on lines 133..137
              src/languageTools/LanguageClient/ServerUtils.js on lines 150..154
              src/languageTools/LanguageClient/ServerUtils.js on lines 156..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 61.

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

                                      resp.process.stderr.on('data', function (data) {
                                          if (global.LanguageClientInfo.preferences.showServerLogsInConsole) {
                                              console.error('[Server logs @ stderr] "%s"', String(data));
                                          }
                                      });
              Severity: Major
              Found in src/languageTools/LanguageClient/ServerUtils.js and 5 other locations - About 1 hr to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 117..121
              src/languageTools/LanguageClient/ServerUtils.js on lines 133..137
              src/languageTools/LanguageClient/ServerUtils.js on lines 150..154
              src/languageTools/LanguageClient/ServerUtils.js on lines 156..160
              src/languageTools/LanguageClient/ServerUtils.js on lines 191..195

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

              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

                                      retval = {
                                          reader: new protocol.StreamMessageReader(resp.process.stdout),
                                          writer: new protocol.StreamMessageWriter(resp.process.stdin)
                                      };
              Severity: Minor
              Found in src/languageTools/LanguageClient/ServerUtils.js and 1 other location - About 45 mins to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 186..189

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

              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

                          retval = {
                              reader: new protocol.StreamMessageReader(resp.process.stdout),
                              writer: new protocol.StreamMessageWriter(resp.process.stdin)
                          };
              Severity: Minor
              Found in src/languageTools/LanguageClient/ServerUtils.js and 1 other location - About 45 mins to fix
              src/languageTools/LanguageClient/ServerUtils.js on lines 139..142

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

              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