packages/miew-cli/src/Miew-cli.js

Summary

Maintainability
F
3 days
Test Coverage

File Miew-cli.js has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Miew } from 'miew'
import { parser as parsercli } from './MiewCLIParser'
import clihelp from './MiewCLIHelp'
import logger from './logger'
import { slice, sortBy, get, keys, isUndefined, set, assign } from 'lodash'
Severity: Minor
Found in packages/miew-cli/src/Miew-cli.js - About 5 hrs to fix

    Function propagateProp has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      propagateProp(path, arg) {
        if (path !== undefined) {
          let argExc = {}
          const adapter = options.adapters[typeof get(settings.defaults, path)]
          if (adapter === undefined) {
    Severity: Minor
    Found in packages/miew-cli/src/Miew-cli.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 getMiewWithCli has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const getMiewWithCli = (miewInstance) => {
      const obj = Object.create(miewInstance)
    
      obj.script = function (script, _printCallback, _errorCallback) {
        parsercli.yy.miew = obj
    Severity: Major
    Found in packages/miew-cli/src/Miew-cli.js - About 2 hrs to fix

      Function getMiewWithCli has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getMiewWithCli = (miewInstance) => {
        const obj = Object.create(miewInstance)
      
        obj.script = function (script, _printCallback, _errorCallback) {
          parsercli.yy.miew = obj
      Severity: Minor
      Found in packages/miew-cli/src/Miew-cli.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 checkArg has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        checkArg(key, arg, modificate) {
          if (key !== undefined && arg !== undefined) {
            if (keyRemap(key) === 'selector') {
              const res = selectors.parse(arg)
      
      
      Severity: Minor
      Found in packages/miew-cli/src/Miew-cli.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 propagateProp has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        propagateProp(path, arg) {
          if (path !== undefined) {
            let argExc = {}
            const adapter = options.adapters[typeof get(settings.defaults, path)]
            if (adapter === undefined) {
      Severity: Minor
      Found in packages/miew-cli/src/Miew-cli.js - About 1 hr to fix

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

          checkArg(key, arg, modificate) {
            if (key !== undefined && arg !== undefined) {
              if (keyRemap(key) === 'selector') {
                const res = selectors.parse(arg)
        
        
        Severity: Minor
        Found in packages/miew-cli/src/Miew-cli.js - About 1 hr to fix

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

            obj._onUpdate = function () {
              if (
                obj.isScriptingCommandAvailable !== undefined &&
                obj.isScriptingCommandAvailable() &&
                !obj._building
          Severity: Minor
          Found in packages/miew-cli/src/Miew-cli.js - About 1 hr to fix

            Function remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              remove(index) {
                if (index && Object.hasOwn(this.representationID, index)) {
                  delete this.representationMap[this.representationID[index]]
                  delete this.representationID[index]
                }
            Severity: Minor
            Found in packages/miew-cli/src/Miew-cli.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

            Function list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              list(miew, repMap, key) {
                let ret = ''
                if (miew && repMap !== undefined) {
                  if (key === undefined || key === '-e') {
                    const count = miew.repCount()
            Severity: Minor
            Found in packages/miew-cli/src/Miew-cli.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

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

            function ArgList(arg) {
              if (arg instanceof this.constructor) {
                return arg
              }
              if (arg instanceof Array) {
            Severity: Major
            Found in packages/miew-cli/src/Miew-cli.js and 2 other locations - About 2 hrs to fix
            packages/miew-cli/dist/index.js on lines 3959..3970
            packages/miew-cli/dist/index.modern.js on lines 3955..3966

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

            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

            function keyRemap(key) {
              const keys = {
                s: 'selector',
                m: 'mode',
                c: 'colorer',
            Severity: Major
            Found in packages/miew-cli/src/Miew-cli.js and 2 other locations - About 2 hrs to fix
            packages/miew-cli/dist/index.js on lines 3759..3774
            packages/miew-cli/dist/index.modern.js on lines 3755..3770

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

            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

                  if (
                    (path.endsWith('.color') ||
                      path.endsWith('.baseColor') ||
                      path.endsWith('.EL.carbon')) &&
                    typeof arg !== 'number'
            Severity: Major
            Found in packages/miew-cli/src/Miew-cli.js and 2 other locations - About 2 hrs to fix
            packages/miew-cli/dist/index.js on lines 3920..3922
            packages/miew-cli/dist/index.modern.js on lines 3916..3918

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

            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

            ArgList.prototype.remove = function (value) {
              const values = this._values
              const index = values.indexOf(value)
              if (index >= 0) {
                values.splice(index, 1)
            Severity: Major
            Found in packages/miew-cli/src/Miew-cli.js and 2 other locations - About 1 hr to fix
            packages/miew-cli/dist/index.js on lines 3976..3983
            packages/miew-cli/dist/index.modern.js on lines 3972..3979

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

            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

            ArgList.prototype.append = function (value) {
              const values = this._values
              values[values.length] = value
              return this
            }
            Severity: Major
            Found in packages/miew-cli/src/Miew-cli.js and 2 other locations - About 45 mins to fix
            packages/miew-cli/dist/index.js on lines 3971..3975
            packages/miew-cli/dist/index.modern.js on lines 3967..3971

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

            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

            There are no issues that match your filters.

            Category
            Status