SuitestAutomation/suitest-js-api

View on GitHub

Showing 179 of 181 total issues

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

const isPlayingComposer = makeModifierComposer(composers.MATCH, ['isPlaying'], (_, data) => ({
    ...data,
    comparator: {
        type: SUBJ_COMPARATOR.MATCH,
        props: [{
Severity: Minor
Found in lib/composers/videoComposers.js and 2 other locations - About 40 mins to fix
lib/composers/videoComposers.js on lines 19..29
lib/composers/videoComposers.js on lines 31..41

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

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

const isPausedComposer = makeModifierComposer(composers.MATCH, ['isPaused'], (_, data) => ({
    ...data,
    comparator: {
        type: SUBJ_COMPARATOR.MATCH,
        props: [{
Severity: Minor
Found in lib/composers/videoComposers.js and 2 other locations - About 40 mins to fix
lib/composers/videoComposers.js on lines 7..17
lib/composers/videoComposers.js on lines 19..29

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

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 positionChain = (x, y) => {
        return makeChain(classInstance, getComposers, {
            type: 'position',
            coordinates: {
                x: validate(validators.ST_VAR_NOT_NEGATIVE_NUMBER, x, invalidInputMessage('position', 'Position x')),
Severity: Minor
Found in lib/chains/positionChain.js and 1 other location - About 35 mins to fix
lib/chains/relativePositionChain.js on lines 111..119

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

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 relativePositionChain = (x, y) => {
        return makeChain(classInstance, getComposers, {
            type: 'position',
            coordinates: {
                x: validate(validators.ST_VAR_OR_NUMBER, x, invalidInputMessage('relativePosition', 'Position x')),
Severity: Minor
Found in lib/chains/relativePositionChain.js and 1 other location - About 35 mins to fix
lib/chains/positionChain.js on lines 131..139

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

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 unusedExpressionWatchersFactory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const unusedExpressionWatchersFactory = ({logger}) => {
    /**
     * Pool of chains, that were not awaited for
     * @type {Set<any>}
     */
Severity: Minor
Found in lib/utils/unusedExpressionWatchers.js - About 35 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 pairDevice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function pairDevice(
    {webSockets, authContext, logger, pairedDeviceContext, config},
    deviceId,
    recordingSettings
) {
Severity: Minor
Found in lib/commands/pairDevice.js - About 35 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 validateRepoProps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const validateRepoProps = ({props, data, text}) => {
    const selector = path(['selector'], data) || {};

    if (has('apiId', selector)) {
        return props;
Severity: Minor
Found in lib/validation/validators.js - About 35 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 getDeviceName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function getDeviceName(deviceInfo, short = false) {
    const {manufacturer, model, customName, deviceId} = deviceInfo;

    let name;

Severity: Minor
Found in lib/utils/getDeviceInfo.js - About 35 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

Avoid too many return statements within this function.
Open

            return;
Severity: Major
Found in lib/utils/socketChainHelper.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return fs.promises
                        .access(dir)
                        .catch(() => fs.promises.mkdir(dir))
                        .then(() => fs.promises.writeFile(data.fileName, res.buffer))
                        .catch(e => {
    Severity: Major
    Found in lib/utils/socketChainHelper.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return 'dismissAlertMessage';
      Severity: Major
      Found in lib/chains/windowChain.js - About 30 mins to fix

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

        const SUBJ_COMPARATOR = {
            EXIST:            'exists',
            VISIBLE:          'visible',
            HAS_EXITED:       'hasExited',
            EQUAL:            '=',
        Severity: Minor
        Found in lib/constants/comparator.js and 2 other locations - About 30 mins to fix
        lib/constants/contentMode.js on lines 3..17
        lib/constants/videoState.js on lines 3..17

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

        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

        Avoid too many return statements within this function.
        Open

                                return subtype === 'time'
                                    ? `Timer '${val1}' already exists`
                                    : `Timer '${val1}' does not exist`;
        Severity: Major
        Found in lib/utils/logger.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return res.buffer;
          Severity: Major
          Found in lib/utils/socketChainHelper.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return 'acceptAlertMessage';
            Severity: Major
            Found in lib/chains/windowChain.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                  return `${val1}: ${val2}`;
              Severity: Major
              Found in lib/utils/logger.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return res.buffer.toString('base64');
                Severity: Major
                Found in lib/utils/socketChainHelper.js - About 30 mins to fix

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

                  const videoState = {
                      STOPPED:            'stopped',
                      ERROR:              'error',
                      PLAYING:            'playing',
                      PAUSED:             'paused',
                  Severity: Minor
                  Found in lib/constants/videoState.js and 2 other locations - About 30 mins to fix
                  lib/constants/comparator.js on lines 3..17
                  lib/constants/contentMode.js on lines 3..17

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

                  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

                  Avoid too many return statements within this function.
                  Open

                                      return val1.join('\n');
                  Severity: Major
                  Found in lib/utils/logger.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return 'acceptPromptMessage';
                    Severity: Major
                    Found in lib/chains/windowChain.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language