packages/miew/src/chem/HBondInfo.js

Summary

Maintainability
F
5 days
Test Coverage

Function _calcHBondEnergy has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _calcHBondEnergy(predonor, donor, acceptor) {
    let result = 0

    if (predonor === null) {
      return result
Severity: Major
Found in packages/miew/src/chem/HBondInfo.js - About 3 hrs to fix

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

      _buildVW() {
        const self = this
        const residues = this._complex._residues
        let ri
        let preri
    Severity: Minor
    Found in packages/miew/src/chem/HBondInfo.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 _calcHBondEnergy has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      _calcHBondEnergy(predonor, donor, acceptor) {
        let result = 0
    
        if (predonor === null) {
          return result
    Severity: Minor
    Found in packages/miew/src/chem/HBondInfo.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 _buildVW has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _buildVW() {
        const self = this
        const residues = this._complex._residues
        let ri
        let preri
    Severity: Major
    Found in packages/miew/src/chem/HBondInfo.js - About 2 hrs to fix

      Function _build has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        _build() {
          const self = this
      
          for (let i = 0; i < this._complex._residues.length - 1; ++i) {
            const ri = this._complex._residues[i]
      Severity: Minor
      Found in packages/miew/src/chem/HBondInfo.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 _build has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _build() {
          const self = this
      
          for (let i = 0; i < this._complex._residues.length - 1; ++i) {
            const ri = this._complex._residues[i]
      Severity: Minor
      Found in packages/miew/src/chem/HBondInfo.js - About 1 hr to fix

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

          isBond(from, to) {
            if (this._hbonds[from]) {
              const [acc0, acc1] = this._hbonds[from].acceptor
              if (acc0 && acc0.residue === to && acc0.energy < MAX_HBOND_ENERGY) {
                return true
        Severity: Minor
        Found in packages/miew/src/chem/HBondInfo.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

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

            if (donorInfo.acceptor.length > 1) {
              if (result < donorInfo.acceptor[0].energy) {
                donorInfo.acceptor[1].residue = donorInfo.acceptor[0].residue
                donorInfo.acceptor[1].energy = donorInfo.acceptor[0].energy
                donorInfo.acceptor[0].residue = acceptor._index
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 1 day to fix
        packages/miew/src/chem/HBondInfo.js on lines 287..297

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

        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

            if (accInfo.donor.length > 1) {
              if (result < accInfo.donor[0].energy) {
                accInfo.donor[1].residue = accInfo.donor[0].residue
                accInfo.donor[1].energy = accInfo.donor[0].energy
                accInfo.donor[0].residue = donor._index
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 1 day to fix
        packages/miew/src/chem/HBondInfo.js on lines 259..269

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

        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

          _residueGetCAlpha(res) {
            for (let i = 0; i < res._atoms.length; ++i) {
              const { name } = res._atoms[i]
              if (name === 'CA' || name === 'C1') {
                return res._atoms[i].position
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 3 hrs to fix
        packages/miew/src/chem/SecondaryStructureMap.js on lines 192..201

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

        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

              if (
                prerj &&
                ((prerj.getType().flags & ResidueType.Flags.PROTEIN) === 0 ||
                  rj._sequence !== prerj._sequence + 1)
              ) {
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 1 hr to fix
        packages/miew/src/chem/HBondInfo.js on lines 134..140

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

        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

              if (
                preri &&
                ((preri.getType().flags & ResidueType.Flags.PROTEIN) === 0 ||
                  ri._sequence !== preri._sequence + 1)
              ) {
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 1 hr to fix
        packages/miew/src/chem/HBondInfo.js on lines 112..118

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

        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

            if (typeof this._hbonds[donor._index] === 'undefined') {
              this._hbonds[donor._index] = {
                donor: [],
                acceptor: []
              }
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 1 hr to fix
        packages/miew/src/chem/HBondInfo.js on lines 272..277

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

        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

            if (typeof this._hbonds[acceptor._index] === 'undefined') {
              this._hbonds[acceptor._index] = {
                donor: [],
                acceptor: []
              }
        Severity: Major
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 1 hr to fix
        packages/miew/src/chem/HBondInfo.js on lines 244..249

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

        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

            if (accInfo.donor.length < 2) {
              accInfo.donor.push({
                residue: donor._index,
                energy: result
              })
        Severity: Minor
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 40 mins to fix
        packages/miew/src/chem/HBondInfo.js on lines 252..257

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

        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

            if (donorInfo.acceptor.length < 2) {
              donorInfo.acceptor.push({
                residue: acceptor._index,
                energy: result
              })
        Severity: Minor
        Found in packages/miew/src/chem/HBondInfo.js and 1 other location - About 40 mins to fix
        packages/miew/src/chem/HBondInfo.js on lines 280..285

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

        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