SuitestAutomation/suitest-js-api

View on GitHub

Showing 123 of 181 total issues

Function webSocketsFactory has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

const webSocketsFactory = (self) => {
    const {config, logger} = self;

    let ws = null,
        requestPromises = {},
Severity: Minor
Found in lib/api/webSockets.js - About 3 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 videoFactory has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

const videoFactory = (classInstance) => {
    const toJSON = data => {
        const type = getRequestType(data);
        const socketMessage = {type};
        const subject = {
Severity: Minor
Found in lib/chains/videoChain.js - About 3 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

File elementChain.js has 307 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const {omit, compose, isNil} = require('ramda');
const SuitestError = require('../../lib/utils/SuitestError');

// Import utils
const makeChain = require('../utils/makeChain');
Severity: Minor
Found in lib/chains/elementChain.js - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

            if (!data.isNegated
                && !data.isAssert
                && !data.isClick
                && !data.tap
                && !data.isSwipe
    Severity: Critical
    Found in lib/chains/elementChain.js - About 3 hrs to fix

      Function networkRequestFactory has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const networkRequestFactory = (classInstance) => {
          const toJSON = data => {
              const type = getRequestType(data);
              const socketMessage = {type};
              const subject = {
      Severity: Major
      Found in lib/chains/networkRequestChain.js - About 3 hrs to fix

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

            const toJSON = data => {
                const type = getRequestType(data);
                const socketMessage = {type};
                const subject = {
                    type: 'element',
        Severity: Major
        Found in lib/chains/elementChain.js - About 3 hrs to fix

          Function cookieFactory has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const cookieFactory = (classInstance) => {
              const toJSON = data => {
                  const type = getRequestType(data);
                  const subject = {type: 'cookie'};
                  const socketMessage = {type};
          Severity: Major
          Found in lib/chains/cookieChain.js - About 3 hrs to fix

            Function positionFactory has 81 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const positionFactory = (classInstance) => {
                const toJSON = (data) => {
                    if (!data.isClick && !data.isMoveTo && !data.tap && !data.isSwipe && !data.isScroll) {
                        throw new SuitestError(positionIsMalformed(), SuitestError.INVALID_INPUT);
                    }
            Severity: Major
            Found in lib/chains/positionChain.js - About 3 hrs to fix

              File logger.js has 297 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const colors = require('colors');
              const logLevels = require('../constants/logLevels');
              const jsonRenderer = require('prettyjson');
              const {formatOpType} = require('./opType');
              const timestamp = require('./timestamp');
              Severity: Minor
              Found in lib/utils/logger.js - About 3 hrs to fix

                Function applicationFactory has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const applicationFactory = (classInstance) => {
                    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: Major
                Found in lib/chains/applicationChain.js - About 3 hrs to fix

                  Function videoFactory has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const videoFactory = (classInstance) => {
                      const toJSON = data => {
                          const type = getRequestType(data);
                          const socketMessage = {type};
                          const subject = {
                  Severity: Major
                  Found in lib/chains/videoChain.js - About 3 hrs to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (!data.isNegated
                                && !data.isClick
                                && !data.tap
                                && !data.isSwipe
                                && !data.isScroll
                    Severity: Critical
                    Found in lib/chains/elementChain.js - About 3 hrs to fix

                      Function readRcConfig has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function readRcConfig(pathToConfig) {
                          let mainConfigFilePath = '';
                      
                          if (pathToConfig) {
                              mainConfigFilePath = pathToConfig;
                      Severity: Minor
                      Found in lib/testLauncher/composeConfig.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 relativePositionFactory has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const relativePositionFactory = (classInstance) => {
                          const toJSON = (data) => {
                              if (!data.isClick && !data.isMoveTo) {
                                  throw new SuitestError(relativePositionIsMalformed(), SuitestError.INVALID_INPUT);
                              }
                      Severity: Major
                      Found in lib/chains/relativePositionChain.js - About 2 hrs to fix

                        Function ocrFactory has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const ocrFactory = (classInstance) => {
                            const toJSON = (data) => {
                                const subject = {type: 'ocr'};
                                const socketMessage = {type: getRequestType(data)};
                        
                        
                        Severity: Major
                        Found in lib/chains/ocrChain.js - About 2 hrs to fix

                          Function brightScriptExpressionFactory has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const brightScriptExpressionFactory = (classInstance) => {
                              const {logger} = classInstance;
                          
                              const toJSON = data => {
                                  const type = getRequestType(data);
                          Severity: Major
                          Found in lib/chains/brightScriptExpressionChain.js - About 2 hrs to fix

                            Function playstationVideoFactory has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const playstationVideoFactory = (classInstance) => {
                                const toJSON = data => {
                                    const type = getRequestType(data);
                                    const socketMessage = {type};
                                    const subject = {
                            Severity: Major
                            Found in lib/chains/playstationVideoChain.js - About 2 hrs to fix

                              Function pressButtonFactory has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const pressButtonFactory = (classInstance) => {
                                  const toJSON = (data) => {
                                      const base = {
                                          type: 'button',
                                          ids: data.ids,
                              Severity: Major
                              Found in lib/chains/pressButtonChain.js - About 2 hrs to fix

                                Function getAppOutput has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        getAppOutput: (subtype, data) => {
                                            // No need to display anything
                                            if (config.logLevel === logLevels.silent) {
                                                return;
                                            }
                                Severity: Major
                                Found in lib/utils/logger.js - About 2 hrs to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                          if (
                                              !data.comparator
                                              && !data.isClick
                                              && !data.isMoveTo
                                              && !data.tap
                                  Severity: Critical
                                  Found in lib/chains/elementChain.js - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language