SuitestAutomation/suitest-js-api

View on GitHub

Showing 175 of 177 total issues

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

          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

            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

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

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

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

                    async runTokenSession() {
                        suitest.logger.intro(t.launcherGreeting, version);
                        validateInput(TOKEN.toUpperCase(), this.ownArgv);
                        const appConfigIdAndDeviceIdPresented = this.ownArgv.appConfigId && this.ownArgv.deviceId;
                        const presetArrayDefined = this.ownArgv.preset && this.ownArgv.preset.length > 0;
                Severity: Major
                Found in lib/testLauncher/SuitestLauncher.js - About 2 hrs to fix

                  Function makeThenComposer has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const makeThenComposer = (getSocketMessage, callback, beforeSend) => makeMethodComposer(
                      composers.THEN,
                      ['then'],
                      ({webSockets, authContext, logger, config, appContext}, data, onResolve, onReject) => {
                          const chainedPromise = chainPromise(async() => {
                  Severity: Minor
                  Found in lib/composers/thenComposer.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 playstationVideoFactory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const playstationVideoFactory = (classInstance) => {
                      const toJSON = data => {
                          const type = getRequestType(data);
                          const socketMessage = {type};
                          const subject = {
                  Severity: Minor
                  Found in lib/chains/playstationVideoChain.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 makeArgumentsProcessor has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const makeArgumentsProcessor = (
                      fromArguments,
                      fromObject = identity,
                      fromObjectArgsValidator = () => true,
                      fromKeyValue = identity,
                  Severity: Minor
                  Found in lib/utils/makeArgumentsProcessor.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

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

                          if (
                              !data.comparator
                              && !data.isClick
                              && !data.isMoveTo
                              && !data.tap
                  Severity: Major
                  Found in lib/chains/elementChain.js and 1 other location - About 2 hrs to fix
                  lib/chains/elementChain.js on lines 253..267

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

                  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 (
                              !data.timeout
                              && !data.isClick
                              && !data.isSwipe
                              && !data.isScroll
                  Severity: Major
                  Found in lib/chains/elementChain.js and 1 other location - About 2 hrs to fix
                  lib/chains/elementChain.js on lines 269..289

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

                  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

                  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

                    Consider simplifying this complex logical expression.
                    Open

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

                      Function testPosition has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function testPosition() {
                          const {position} = suitest;
                      
                          const samplePos = position(100, 100);
                      
                      
                      Severity: Major
                      Found in testDefinition/examplesTS/positionChain.ts - About 2 hrs to fix

                        Function openAppChainFactory has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const openAppChainFactory = (classInstance) => {
                            const toJSON = data => {
                                const socketMessage = {
                                    type: getRequestType(data, false),
                                    request: {
                        Severity: Major
                        Found in lib/chains/openAppChain.js - About 2 hrs to fix

                          Function saveScreenshotFactory has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const saveScreenshotFactory = (classInstance) => {
                              function getPlaceholdersValues(date = new Date()) {
                                  const userStackItem = getFirstNotSuitestStackItem();
                          
                                  return {
                          Severity: Major
                          Found in lib/chains/saveScreenshotChain.js - About 2 hrs to fix

                            Function javascriptExpressionFactory has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const javascriptExpressionFactory = (classInstance) => {
                                const toJSON = data => {
                                    const type = getRequestType(data);
                                    const socketMessage = {type};
                            
                            
                            Severity: Minor
                            Found in lib/chains/javascriptExpressionChain.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

                            Severity
                            Category
                            Status
                            Source
                            Language