packages/miew/src/io/parsers/CIFParser.js

Summary

Maintainability
F
3 days
Test Coverage

File CIFParser.js has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Parser from './Parser'
import chem from '../../chem'
import StructuralElement from '../../chem/StructuralElement'
import readCIF from './readCIF'
import { isArray, isString } from 'lodash'
Severity: Minor
Found in packages/miew/src/io/parsers/CIFParser.js - About 6 hrs to fix

    Function _extractAtoms has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _extractAtoms(complex, complexData) {
        const atomData = complexData.atom_site
        if (!atomData) {
          throw new AtomDataError('CIF parsing error: atom_site is not specified!')
        }
    Severity: Major
    Found in packages/miew/src/io/parsers/CIFParser.js - About 3 hrs to fix

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

      function _extractOperations(assemblyGen, opsDict) {
        assemblyGen = isString(assemblyGen) ? assemblyGen : `${assemblyGen}`
        const l = assemblyGen.replace(/\)\s*\(/g, '!').replace(/[()']/g, '')
        const groupStr = l.split('!')
        const gps = []
      Severity: Minor
      Found in packages/miew/src/io/parsers/CIFParser.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 _extractConfs has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _extractConfs(complex, helicesData) {
          const { asymDict } = this
          if (
            !helicesData.conf_type_id ||
            !helicesData.beg_label_seq_id ||
      Severity: Major
      Found in packages/miew/src/io/parsers/CIFParser.js - About 2 hrs to fix

        Function _extractSheets has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _extractSheets(complex, sheetData) {
            const { asymDict } = this
            if (
              !sheetData.sheet_id ||
              !sheetData.id ||
        Severity: Minor
        Found in packages/miew/src/io/parsers/CIFParser.js - About 1 hr to fix

          Function _extractAtoms has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            _extractAtoms(complex, complexData) {
              const atomData = complexData.atom_site
              if (!atomData) {
                throw new AtomDataError('CIF parsing error: atom_site is not specified!')
              }
          Severity: Minor
          Found in packages/miew/src/io/parsers/CIFParser.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 _extractConfs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            _extractConfs(complex, helicesData) {
              const { asymDict } = this
              if (
                !helicesData.conf_type_id ||
                !helicesData.beg_label_seq_id ||
          Severity: Minor
          Found in packages/miew/src/io/parsers/CIFParser.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 _extractOperations has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function _extractOperations(assemblyGen, opsDict) {
            assemblyGen = isString(assemblyGen) ? assemblyGen : `${assemblyGen}`
            const l = assemblyGen.replace(/\)\s*\(/g, '!').replace(/[()']/g, '')
            const groupStr = l.split('!')
            const gps = []
          Severity: Minor
          Found in packages/miew/src/io/parsers/CIFParser.js - About 1 hr to fix

            Function _extractSheets has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              _extractSheets(complex, sheetData) {
                const { asymDict } = this
                if (
                  !sheetData.sheet_id ||
                  !sheetData.id ||
            Severity: Minor
            Found in packages/miew/src/io/parsers/CIFParser.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 _extractAssemblies has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _extractAssemblies(complex, complexData) {
                const { asymDict } = this
                const asmGen = complexData.pdbx_struct_assembly_gen
                if (!asmGen) {
                  return
            Severity: Minor
            Found in packages/miew/src/io/parsers/CIFParser.js - About 1 hr to fix

              Function _extractAssemblies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                _extractAssemblies(complex, complexData) {
                  const { asymDict } = this
                  const asmGen = complexData.pdbx_struct_assembly_gen
                  if (!asmGen) {
                    return
              Severity: Minor
              Found in packages/miew/src/io/parsers/CIFParser.js - About 55 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 _getOperations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function _getOperations(operList) {
                if (!operList) {
                  return null
                }
                const idc = arrize(operList.id)
              Severity: Minor
              Found in packages/miew/src/io/parsers/CIFParser.js - About 25 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 2 locations. Consider refactoring.
              Open

              function nameToElement(name) {
                // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM
                //
                // http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#note1
                //
              Severity: Major
              Found in packages/miew/src/io/parsers/CIFParser.js and 1 other location - About 1 hr to fix
              packages/miew/src/io/parsers/PDBParser.js on lines 13..27

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

              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

                  complex.finalize({
                    needAutoBonding: true,
                    detectAromaticLoops: this.settings.now.aromatic,
                    enableEditing: this.settings.now.editing
                  })
              Severity: Minor
              Found in packages/miew/src/io/parsers/CIFParser.js and 1 other location - About 50 mins to fix
              packages/miew/src/io/parsers/PubChemParser.js on lines 28..32

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

              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

                    for (let r = start[1]; r <= end[1]; ++r) {
                      residues[r]._secondary = struct
                    }
              Severity: Minor
              Found in packages/miew/src/io/parsers/CIFParser.js and 1 other location - About 35 mins to fix
              packages/miew/src/io/parsers/CIFParser.js on lines 413..415

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

              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

                    for (let r = start[1]; r <= end[1]; ++r) {
                      residues[r]._secondary = strand
                    }
              Severity: Minor
              Found in packages/miew/src/io/parsers/CIFParser.js and 1 other location - About 35 mins to fix
              packages/miew/src/io/parsers/CIFParser.js on lines 501..503

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

              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

              class AtomDataError extends Error {
                constructor(message) {
                  super()
                  this.name = 'AtomDataError'
                  this.message = message
              Severity: Minor
              Found in packages/miew/src/io/parsers/CIFParser.js and 2 other locations - About 30 mins to fix
              packages/miew-cli/src/utils.js on lines 260..266
              packages/miew/src/utils.js on lines 260..266

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

              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