SuitestAutomation/suitest-js-api

View on GitHub

Showing 175 of 177 total issues

Function createLogger has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
Open

const createLogger = (config, pairedDeviceContext) => {
    /**
     * Prefix log with device id
     */
    function devicePrefix() {
Severity: Minor
Found in lib/utils/logger.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 elementFactory has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

const elementFactory = (classInstance, video) => {
    const toJSON = data => {
        const type = getRequestType(data);
        const socketMessage = {type};
        const subject = {
Severity: Minor
Found in lib/chains/elementChain.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 elementFactory has 239 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const elementFactory = (classInstance, video) => {
    const toJSON = data => {
        const type = getRequestType(data);
        const socketMessage = {type};
        const subject = {
Severity: Major
Found in lib/chains/elementChain.js - About 1 day to fix

    Function webSocketsFactory has 220 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const webSocketsFactory = (self) => {
        const {config, logger} = self;
    
        let ws = null,
            requestPromises = {},
    Severity: Major
    Found in lib/api/webSockets.js - About 1 day to fix

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

      const suspendAppChainFactory = (classInstance) => {
          const toJSON = data => ({
              type: getRequestType(data, false),
              request: {
                  type: 'suspendApp',
      Severity: Major
      Found in lib/chains/suspendAppChain.js and 1 other location - About 1 day to fix
      lib/chains/closeAppChain.js on lines 14..64

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

      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

      const closeAppChainFactory = (classInstance) => {
          const toJSON = data => ({
              type: getRequestType(data, false),
              request: {
                  type: 'closeApp',
      Severity: Major
      Found in lib/chains/closeAppChain.js and 1 other location - About 1 day to fix
      lib/chains/suspendAppChain.js on lines 14..64

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

      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

      File jsonSchemas.js has 472 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const {uniq, values} = require('ramda');
      const validationKeys = require('../constants/validationKeys');
      const {NETWORK_PROP, NETWORK_METHOD} = require('../constants/networkRequest');
      const {PROP_COMPARATOR} = require('../constants/comparator');
      const {ELEMENT_PROP, VALUE} = require('../constants/element');
      Severity: Minor
      Found in lib/validation/jsonSchemas.js - About 7 hrs to fix

        Function createLogger has 180 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const createLogger = (config, pairedDeviceContext) => {
            /**
             * Prefix log with device id
             */
            function devicePrefix() {
        Severity: Major
        Found in lib/utils/logger.js - About 7 hrs to fix

          Function windowFactory has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
          Open

          const windowFactory = (classInstance) => {
              /**
               * @description get browser command type basing on internal chain data
               * @param data
               * @returns {'refresh' | 'goBack' | 'goForward' | 'setWindowSize' | 'dismissAlertMessage' | 'acceptPromptMessage' | 'acceptAlertMessage'}
          Severity: Minor
          Found in lib/chains/windowChain.js - About 6 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

              const toJSON = data => {
                  const type = getRequestType(data);
                  const socketMessage = {type};
          
                  if (type === 'query') {
          Severity: Major
          Found in lib/chains/javascriptExpressionChain.js and 1 other location - About 6 hrs to fix
          lib/chains/brightScriptExpressionChain.js on lines 35..66

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

          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

              const toJSON = data => {
                  const type = getRequestType(data);
                  const socketMessage = {type};
          
                  if (type === 'query') {
          Severity: Major
          Found in lib/chains/brightScriptExpressionChain.js and 1 other location - About 6 hrs to fix
          lib/chains/javascriptExpressionChain.js on lines 32..60

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

          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

              const getComposers = data => {
                  const output = [
                      toStringComposer,
                      thenComposer,
                      cloneComposer,
          Severity: Major
          Found in lib/chains/javascriptExpressionChain.js and 1 other location - About 6 hrs to fix
          lib/chains/brightScriptExpressionChain.js on lines 79..109

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

          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

              const getComposers = data => {
                  const output = [
                      toStringComposer,
                      thenComposer,
                      cloneComposer,
          Severity: Major
          Found in lib/chains/brightScriptExpressionChain.js and 1 other location - About 6 hrs to fix
          lib/chains/javascriptExpressionChain.js on lines 73..103

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

          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

          Function processServerResponse has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
          Open

          const processServerResponse = (logger, verbosity) =>
              function processServerResponseHandler(res, data, jsonMessage, snippets) {
                  const isSnippet = data.type === 'runSnippet';
                  const isAssertionError = isSnippet || assertionErrorTypes.includes(normalizeErrorType(res));
                  const responseForError = getResponseForError(res);
          Severity: Minor
          Found in lib/utils/socketChainHelper.js - About 6 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 constructor has 145 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              constructor({exitOnError} = {}) {
                  super();
          
                  // instance dependencies
                  this.authContext = new AuthContext();
          Severity: Major
          Found in suitest.js - About 5 hrs to fix

            Function connect has 144 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function connect(connectionOps = {}) {
                    disconnect();
                    logger.debug('Initializing websocket connection with options:', connectionOps);
            
                    if (!connectionOps.headers) {
            Severity: Major
            Found in lib/api/webSockets.js - About 5 hrs to fix

              Function networkRequestFactory has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

              const networkRequestFactory = (classInstance) => {
                  const toJSON = data => {
                      const type = getRequestType(data);
                      const socketMessage = {type};
                      const subject = {
              Severity: Minor
              Found in lib/chains/networkRequestChain.js - About 5 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 positionFactory has a Cognitive Complexity of 33 (exceeds 5 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: Minor
              Found in lib/chains/positionChain.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 getComposers has 122 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const getComposers = (data) => {
                      const output = [
                          toStringComposer,
                          thenComposer,
                          cloneComposer,
              Severity: Major
              Found in lib/chains/elementChain.js - About 4 hrs to fix

                Function processServerResponseHandler has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function processServerResponseHandler(res, data, jsonMessage, snippets) {
                        const isSnippet = data.type === 'runSnippet';
                        const isAssertionError = isSnippet || assertionErrorTypes.includes(normalizeErrorType(res));
                        const responseForError = getResponseForError(res);
                        const message = getErrorMessage({
                Severity: Major
                Found in lib/utils/socketChainHelper.js - About 4 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language