SuitestAutomation/suitest-js-api

View on GitHub

Showing 123 of 181 total issues

Function toJSON has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const toJSON = (data) => {
        if (!data.isClick && !data.isMoveTo && !data.tap && !data.isSwipe && !data.isScroll) {
            throw new SuitestError(positionIsMalformed(), SuitestError.INVALID_INPUT);
        }

Severity: Minor
Found in lib/chains/positionChain.js - About 1 hr to fix

    Function getComposers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const getComposers = data => {
            const output = [
                toStringComposer,
                thenComposer,
                gettersComposer,
    Severity: Minor
    Found in lib/chains/networkRequestChain.js - About 1 hr to fix

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

      function handleResponse(msg) {
          const messageId = msg.messageId;
          const res = msg.content.response || msg.content;
          const req = requestPromises[messageId];
      
      
      Severity: Minor
      Found in lib/utils/testHelpers/mockWebSocket.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 bootstrapSession has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      const bootstrapSession = async(suitest, {deviceId, configId, presetName}) => {
          try {
              if (suitest.config.sessionType === TOKEN) {
                  validate(validators.SESSION_BOOTSTRAP_TOKEN, suitest.config, 'suitest token configuration');
                  await openSession(
      Severity: Minor
      Found in lib/utils/sessionStarter.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 getComposers has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const getComposers = (data) => {
              const output = [
                  toStringComposer,
                  thenComposer,
                  cloneComposer,
      Severity: Minor
      Found in lib/chains/windowChain.js - About 1 hr to fix

        Function startREPL has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async function startREPL(opts = {}) {
            if (!replModeWasActivated) {
                replModeWasActivated = true;
                captureMessage('REPL mode activated');
            }
        Severity: Minor
        Found in lib/commands/startREPL.js - About 1 hr to fix

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

              const toJSON = data => {
                  const type = getRequestType(data);
                  const socketMessage = {type};
                  const subject = {
                      type: 'psVideo',
          Severity: Minor
          Found in lib/chains/playstationVideoChain.js - About 1 hr to fix

            Function takeScreenshotFactory has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const takeScreenshotFactory = (classInstance) => {
                const toJSON = () => ({type: 'takeScreenshot'});
            
                const toStringComposer = makeToStringComposer(toJSON);
                const thenComposer = makeThenComposer(toJSON);
            Severity: Minor
            Found in lib/chains/takeScreenshotChain.js - About 1 hr to fix

              Function handleResponse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function handleResponse(msg) {
                      const messageId = msg.messageId;
                      const res = msg.content.response || msg.content;
                      const req = requestPromises[messageId];
              
              
              Severity: Minor
              Found in lib/api/webSockets.js - About 1 hr to fix

                Function toJSON has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const toJSON = data => {
                        if (isNil(data.sendText) && (!data.comparator || data.comparator.type !== SUBJ_COMPARATOR.HAS_EXITED)) {
                            // Application can only be of "hasExited()" eval / assert
                            throw new SuitestError(applicationCommandMalformed(), SuitestError.INVALID_INPUT);
                        }
                Severity: Minor
                Found in lib/chains/applicationChain.js - About 1 hr to fix

                  Function getComposers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const getComposers = (data) => {
                          const output = [
                              toStringComposer,
                              thenComposer,
                              cloneComposer,
                  Severity: Minor
                  Found in lib/chains/positionChain.js - About 1 hr to fix

                    Function getComposers has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        const getComposers = (data) => {
                            const output = [
                                toStringComposer,
                                thenComposer,
                                cloneComposer,
                    Severity: Minor
                    Found in lib/chains/relativePositionChain.js - About 1 hr to fix

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

                          function createDeviceLogger() {
                              let logTime = 0;
                      
                              // Create transform stream to prepend our custom prefix to each output new line.
                              const transformStream = new Transform({
                      Severity: Minor
                      Found in lib/utils/logger.js - About 1 hr to fix

                        Function toJSON has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            const toJSON = data => {
                                const type = getRequestType(data);
                                const socketMessage = {type};
                        
                                if (type === 'query') {
                        Severity: Minor
                        Found in lib/chains/brightScriptExpressionChain.js - About 1 hr to fix

                          Function start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const start = config => {
                              const server = net.createServer();
                          
                              state.server = server;
                          
                          
                          Severity: Minor
                          Found in lib/testLauncher/ipc/server.js - About 1 hr to fix

                            Function request has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            async function request(url, requestObject, onFail) {
                                if (requestObject.body) {
                                    requestObject.body = JSON.stringify(requestObject.body);
                            
                                    if (!requestObject.headers) {
                            Severity: Minor
                            Found in lib/api/request.js - About 1 hr to fix

                              Function getComposers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  const getComposers = (data) => {
                                      const output = [
                                          toStringComposer,
                                          thenComposer,
                                          cloneComposer,
                              Severity: Minor
                              Found in lib/chains/playstationVideoChain.js - About 1 hr to fix

                                Function toJSON has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    const toJSON = data => {
                                        const type = getRequestType(data);
                                        const subject = {type: 'cookie'};
                                        const socketMessage = {type};
                                
                                
                                Severity: Minor
                                Found in lib/chains/cookieChain.js - About 1 hr to fix

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

                                  const composeConfig = (argv) => {
                                      if (argv.configFile) {
                                          console.warn('Warning: You are using deprecated argument --config-file. Please use --override-config-file or --base-config-file instead.');
                                          if (argv.baseConfigFile || argv.overrideConfigFile) {
                                              throw new SuitestError('Combination of deprecated --config-file with either --base-config-file or --override-config-file is not allowed');
                                  Severity: Minor
                                  Found in lib/testLauncher/composeConfig.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 getSnippetLogs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  const getSnippetLogs = ({testId, definitions, results, level, verbosity}, translate = chainUtils.translateLineResult) => {
                                      const indent = ' '.repeat(level);
                                      // Indent all text by indent constant
                                      const applyIndent = (str) => str.split('\n').map(l => indent + l).join('\n');
                                      // array of definition without comments to get right def based on lineId in results
                                  Severity: Minor
                                  Found in lib/utils/socketErrorMessages.js - About 45 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language