Showing 518 of 535 total issues

File Miew.js has 3114 lines of code (exceeds 500 allowed). Consider refactoring.
Open

/* global PACKAGE_VERSION:false */
import _ from 'lodash';
import * as THREE from 'three';
import { Spinner } from 'spin.js';
import Stats from './gfx/Stats';
Severity: Major
Found in packages/lib/src/Miew.js - About 1 wk to fix

    File Menu.js has 1972 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    /* eslint-disable quote-props */
    /* eslint-disable prefer-destructuring */
    import $ from 'jquery';
    import _ from 'lodash';
    // waiting for fix https://github.com/benmosher/eslint-plugin-import/issues/1712
    Severity: Major
    Found in packages/lib/demo/scripts/ui/Menu.js - About 4 days to fix

      Function readCIF has a Cognitive Complexity of 142 (exceeds 15 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/lib/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 _buildBetaSheets has a Cognitive Complexity of 135 (exceeds 15 allowed). Consider refactoring.
      Open

        _buildBetaSheets() {
          // find bridges
          // check each chain against each other chain, and against itself
          const bridges = [];
          for (let a = 0; a < this._complex._chains.length; ++a) {
      Severity: Minor
      Found in packages/lib/src/chem/SecondaryStructureMap.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 ContactSurface has a Cognitive Complexity of 122 (exceeds 15 allowed). Consider refactoring.
      Open

      function ContactSurface(packedArrays, boundaries, params, _indexList) {
        // Field generation method adapted from AstexViewer (Mike Hartshorn)
        // by Fred Ludlow.
        // Other parts based heavily on NGL (Alexander Rose) EDT Surface class
        //
      Severity: Minor
      Found in packages/lib/src/gfx/geometries/ContactSurface.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

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

      class ResiduesGroup extends ChemGroup {
        raycast(raycaster, intersects) {
          const { residues } = this._selection;
          const inters = [];
          this._mesh.raycast(raycaster, inters);
      Severity: Major
      Found in packages/lib/src/gfx/modes/groups/ResiduesGroup.js and 1 other location - About 1 day to fix
      packages/lib/src/gfx/modes/groups/AtomsGroup.js on lines 3..34

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

      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

      class AtomsGroup extends ChemGroup {
        raycast(raycaster, intersects) {
          const { atoms } = this._selection;
          const inters = [];
          this._mesh.raycast(raycaster, inters);
      Severity: Major
      Found in packages/lib/src/gfx/modes/groups/AtomsGroup.js and 1 other location - About 1 day to fix
      packages/lib/src/gfx/modes/groups/ResiduesGroup.js on lines 3..34

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

      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 ContactSurface has 326 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      function ContactSurface(packedArrays, boundaries, params, _indexList) {
        // Field generation method adapted from AstexViewer (Mike Hartshorn)
        // by Fred Ludlow.
        // Other parts based heavily on NGL (Alexander Rose) EDT Surface class
        //
      Severity: Major
      Found in packages/lib/src/gfx/geometries/ContactSurface.js - About 1 day to fix

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

        ObjectControls.prototype.handleResize = function () {
          if (this.domElement === document) {
            this.screen.left = 0;
            this.screen.top = 0;
            this.screen.width = window.innerWidth;
        Severity: Major
        Found in packages/lib/src/ui/ObjectControls.js and 1 other location - About 1 day to fix
        packages/lib/src/ui/Picker.js on lines 85..100

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

        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

        Picker.prototype.handleResize = function () {
          if (this.domElement === document) {
            this.screen.left = 0;
            this.screen.top = 0;
            this.screen.width = window.innerWidth;
        Severity: Major
        Found in packages/lib/src/ui/Picker.js and 1 other location - About 1 day to fix
        packages/lib/src/ui/ObjectControls.js on lines 420..435

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

        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

          _fixBondsArray() {
            const serialAtomMap = this._serialAtomMap = {};
            const complex = this._complex;
        
            const atoms = complex._atoms;
        Severity: Major
        Found in packages/lib/src/io/parsers/CMLParser.js and 1 other location - About 1 day to fix
        packages/lib/src/io/parsers/PDBParser.js on lines 137..157

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

        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

          _fixBondsArray() {
            const serialAtomMap = this._serialAtomMap = {};
            const complex = this._complex;
        
            const atoms = complex._atoms;
        Severity: Major
        Found in packages/lib/src/io/parsers/PDBParser.js and 1 other location - About 1 day to fix
        packages/lib/src/io/parsers/CMLParser.js on lines 447..467

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

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

          _buildAlphaHelices(inResidues, chainLength, inPreferPiHelices) {
            // Helix and Turn
            for (let stride = 3; stride <= 5; ++stride) {
              if (inResidues.length < stride) {
                break;
        Severity: Minor
        Found in packages/lib/src/chem/SecondaryStructureMap.js - About 1 day 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

        Complex has 65 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Complex {
          constructor() {
            this._chains = [];
            this._components = [];
            this._helices = [];
        Severity: Major
        Found in packages/lib/src/chem/Complex.js - About 1 day to fix

          Function _addReprListItem has 236 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          Menu.prototype._addReprListItem = function (panel, index, repr) {
            const self = this;
            const reprList = $(`${self._menuId} [data-panel-type=miew-menu-panel-representation] .miew-repr-list`);
            const validReprN = reprList.find('.panel.valid').length;
            const newItem = createElement('div', {
          Severity: Major
          Found in packages/lib/demo/scripts/ui/Menu.js - About 1 day to fix

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

            function _getSphereSliceRadiusRange(center, radius, zMin, zMax) {
              const dzMin = zMin - center.z;
              const dzMax = zMax - center.z;
              const rzMin = Math.sqrt(Math.max(radius * radius - dzMin * dzMin, 0.0));
              const rzMax = Math.sqrt(Math.max(radius * radius - dzMax * dzMax, 0.0));
            Severity: Major
            Found in packages/lib/src/chem/VoxelWorld.js and 1 other location - About 1 day to fix
            packages/lib/src/chem/VoxelWorld.js on lines 43..60

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

            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

            function _getCircleSliceRadiusRange(center, radius, yMin, yMax) {
              const dyMin = yMin - center.y;
              const dyMax = yMax - center.y;
              const ryMin = Math.sqrt(Math.max(radius * radius - dyMin * dyMin, 0.0));
              const ryMax = Math.sqrt(Math.max(radius * radius - dyMax * dyMax, 0.0));
            Severity: Major
            Found in packages/lib/src/chem/VoxelWorld.js and 1 other location - About 1 day to fix
            packages/lib/src/chem/VoxelWorld.js on lines 12..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 201.

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

              _parseSet(varData) {
                const complex = this._complex = new Complex();
                const data = varData;
                const currentLabel = data.curr;
                const { atoms, labels } = data;
            Severity: Minor
            Found in packages/lib/src/io/parsers/CMLParser.js - About 1 day 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/lib/src/chem/HBondInfo.js and 1 other location - About 1 day to fix
            packages/lib/src/chem/HBondInfo.js on lines 262..272

            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/lib/src/chem/HBondInfo.js and 1 other location - About 1 day to fix
            packages/lib/src/chem/HBondInfo.js on lines 234..244

            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

            Severity
            Category
            Status
            Source
            Language