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

Summary

Maintainability
F
5 days
Test Coverage

Function readCIF has a Cognitive Complexity of 142 (exceeds 5 allowed). Consider refactoring.
Open

export default function readCIF(source) {
  let i = 0
  let j = 0
  const n = source.length
  let code = NaN
Severity: Minor
Found in packages/miew/src/io/parsers/readCIF.js - About 2 days 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 readCIF has 256 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function readCIF(source) {
  let i = 0
  let j = 0
  const n = source.length
  let code = NaN
Severity: Major
Found in packages/miew/src/io/parsers/readCIF.js - About 1 day to fix

    File readCIF.js has 275 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { set } from 'lodash'
    import ParsingError from './ParsingError'
    
    // Implemented and being tested against: https://www.iucr.org/resources/cif/spec/version1.1/cifsyntax
    
    
    Severity: Minor
    Found in packages/miew/src/io/parsers/readCIF.js - About 2 hrs to fix

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

        function _parseValue() {
          let val
          if (
            (code === 46 || code === 63) &&
            (i + 1 >= n || _isWhitespace(source.charCodeAt(i + 1)))
      Severity: Major
      Found in packages/miew/src/io/parsers/readCIF.js - About 2 hrs to fix

        Avoid deeply nested control flow statements.
        Open

                if (
                  (code === 68 || code === 100) &&
                  source.substr(i + 1, 4).toLowerCase() === 'ata_'
                ) {
                  // 'data_' ..........
        Severity: Major
        Found in packages/miew/src/io/parsers/readCIF.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                } else if (state === 1) {
                  // block =============================================================================
                  if (
                    (code === 68 || code === 100) &&
                    source.substr(i + 1, 4).toLowerCase() === 'ata_'
          Severity: Major
          Found in packages/miew/src/io/parsers/readCIF.js - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

                return val
            Severity: Major
            Found in packages/miew/src/io/parsers/readCIF.js - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status