JensKrumsieck/ChemSharp

View on GitHub

Showing 28 of 30 total issues

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

    public Atom ParseAtom(ReadOnlySpan<char> line)
    {
        var cols = line.WhiteSpaceSplit();
        var x = line.Slice(cols[0].start, cols[0].length).ToSingle();
        var y = line.Slice(cols[1].start, cols[1].length).ToSingle();
Severity: Major
Found in ChemSharp.Molecules/Formats/MolFormat.cs and 1 other location - About 3 hrs to fix
ChemSharp.Molecules/Formats/XYZFormat.cs on lines 12..20

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

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

    public Atom ParseAtom(ReadOnlySpan<char> line)
    {
        var cols = line.WhiteSpaceSplit();
        var symbol = line.Slice(cols[0].start, cols[0].length).ToString();
        var x = line.Slice(cols[1].start, cols[1].length).ToSingle();
Severity: Major
Found in ChemSharp.Molecules/Formats/XYZFormat.cs and 1 other location - About 3 hrs to fix
ChemSharp.Molecules/Formats/MolFormat.cs on lines 19..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 245.

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

    private void ExtractHeaderComp(ReadOnlySpan<char> line)
    {
        if (line.StartsWith(HeaderLabelComp.AsSpan())) _colLabel = _idh;
        if (line.StartsWith(HeaderSymbolComp.AsSpan())) _colSymbol = _idh;
        if (line.StartsWith(HeaderCartXComp.AsSpan())) _colX = _idh;
Severity: Major
Found in ChemSharp.Molecules/Formats/CifFormat_Comp.cs and 1 other location - About 2 hrs to fix
ChemSharp.Molecules/Formats/CifFormat_CCDC.cs on lines 51..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 169.

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

    private void ExtractHeaderCCDC(ReadOnlySpan<char> line)
    {
        if (line.StartsWith(HeaderLabelCCDC.AsSpan())) _colLabel = _idh;
        if (line.StartsWith(HeaderSymbolCCDC.AsSpan())) _colSymbol = _idh;
        if (line.StartsWith(HeaderFractX.AsSpan())) _colX = _idh;
Severity: Major
Found in ChemSharp.Molecules/Formats/CifFormat_CCDC.cs and 1 other location - About 2 hrs to fix
ChemSharp.Molecules/Formats/CifFormat_Comp.cs on lines 15..24

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

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

Method Execute has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void Execute(GeneratorExecutionContext context)
    {
        var formats = context.GetClassesImplementing("IAtomFileFormat").ToList();
        var sb = new StringBuilder(@"
        using System.IO;
Severity: Minor
Found in Generators/ChemSharp.Molecules.Generator/MoleculeCreateGenerator.cs - About 1 hr to fix

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

    public static class ResourceUtil
    {
        /// <summary>
        ///     Loads ResourceStream
        /// </summary>
    Severity: Major
    Found in Generators/ChemSharp.Molecules.Generator/ResourceUtil.cs and 1 other location - About 1 hr to fix
    ChemSharp/Extensions/ResourceUtil.cs on lines 5..35

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

    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

    public static class ResourceUtil
    {
        /// <summary>
        ///     Loads ResourceStream
        /// </summary>
    Severity: Major
    Found in ChemSharp/Extensions/ResourceUtil.cs and 1 other location - About 1 hr to fix
    Generators/ChemSharp.Molecules.Generator/ResourceUtil.cs on lines 5..35

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

    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

        public static string TryGetInt(this JsonElement jsonObject, string propertyName)
        {
            if (!jsonObject.TryGetProperty(propertyName, out var value))
                return 0.ToString(CultureInfo.InvariantCulture);
            if (value.ValueKind != JsonValueKind.Number)
    Severity: Major
    Found in Generators/ChemSharp.Molecules.Generator/JsonTools.cs and 1 other location - About 1 hr to fix
    Generators/ChemSharp.Molecules.Generator/JsonTools.cs on lines 26..35

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

    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

        public static string TryGetDouble(this JsonElement jsonObject, string propertyName)
        {
            if (!jsonObject.TryGetProperty(propertyName, out var value))
                return 0d.ToString(CultureInfo.InvariantCulture);
            if (value.ValueKind != JsonValueKind.Number)
    Severity: Major
    Found in Generators/ChemSharp.Molecules.Generator/JsonTools.cs and 1 other location - About 1 hr to fix
    Generators/ChemSharp.Molecules.Generator/JsonTools.cs on lines 15..24

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

    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

    Method CountElements has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static Dictionary<string, double> CountElements(this string formula, CultureInfo ci)
        {
            formula = formula.RemoveAbbreviations(); //remove special abbreviations
            var parse = RegexUtil.SumFormula.Matches(formula);
            var stack = new Stack<Dictionary<string, double>>();
    Severity: Minor
    Found in ChemSharp.Molecules/Extensions/SumFormulaUtil.cs - About 1 hr to fix

      Method ExportToString has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static string ExportToString(Spectrum spc, char separator,
                                              SpectrumExportFlags flags = SpectrumExportFlags.Experimental)
          {
              var exp = flags.HasFlag(SpectrumExportFlags.Experimental);
              var deriv = flags.HasFlag(SpectrumExportFlags.Derivative);
      Severity: Minor
      Found in ChemSharp.Spectroscopy/Export/CSVExporter.cs - About 1 hr to fix

        Method Export has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public override void Export(IExportable exportable, Stream stream)
            {
                base.Export(exportable, stream);
                if (Molecule == null) return;
                var atomsCount = Molecule.Atoms.Count;
        Severity: Minor
        Found in ChemSharp.Molecules/Export/PDBExporter.cs - About 1 hr to fix

          Method SetPickingIndicator has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void SetPickingIndicator(ReadOnlySpan<char> line)
              {
                  //determine whether to check for atoms or bonds
                  if (line.StartsWith(AtomsBlock.AsSpan()))
                  {
          Severity: Minor
          Found in ChemSharp.Molecules/Formats/Mol2Format.cs - About 1 hr to fix

            Function addBond has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function addBond(x: number, y: number, z: number, qx: number, qy: number, qz: number, qw: number, length: number) {
            Severity: Major
            Found in ChemSharp.Molecules.Blazor/assets/src/index.ts - About 1 hr to fix

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

                      foreach (var format in formats)
                      {
                          var ext = format.Identifier.ValueText.Split(new[] {"Format"}, StringSplitOptions.RemoveEmptyEntries)[0]
                                          .ToLower();
                          sb.AppendLine($@"""{ext}"" => {format.Identifier.ValueText}.ReadFromStream(stream),");
              Generators/ChemSharp.Molecules.Generator/MoleculeCreateGenerator.cs on lines 38..43

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

              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

                      foreach (var format in formats)
                      {
                          var ext = format.Identifier.ValueText.Split(new[] {"Format"}, StringSplitOptions.RemoveEmptyEntries)[0]
                                          .ToLower();
                          sb.AppendLine($@"""{ext}"" => {format.Identifier.ValueText}.Read(path),");
              Generators/ChemSharp.Molecules.Generator/MoleculeCreateGenerator.cs on lines 52..57

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

              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 addAtom has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              export function addAtom(name: string, symbol: string, x: number, y: number, z: number, radius: number, color: string) {
              Severity: Major
              Found in ChemSharp.Molecules.Blazor/assets/src/index.ts - About 50 mins to fix

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

                    private void SetPickingIndicatorComp(ReadOnlySpan<char> line)
                    {
                        //determine whether to check for atoms or bonds
                        if (line.StartsWith(AtomsLoopComp.AsSpan()))
                        {
                Severity: Minor
                Found in ChemSharp.Molecules/Formats/CifFormat_Comp.cs and 1 other location - About 50 mins to fix
                ChemSharp.Molecules/Formats/CifFormat_CCDC.cs on lines 78..91

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

                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

                    private void SetPickingIndicatorCCDC(ReadOnlySpan<char> line)
                    {
                        //determine whether to check for atoms or bonds
                        if (line.StartsWith(AtomsLoopCCDC.AsSpan()))
                        {
                Severity: Minor
                Found in ChemSharp.Molecules/Formats/CifFormat_CCDC.cs and 1 other location - About 50 mins to fix
                ChemSharp.Molecules/Formats/CifFormat_Comp.cs on lines 26..39

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

                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 (integral)
                            {
                                line.Append(spc.Integral[i].X.ToInvariantString() + separator);
                                line.Append(spc.Integral[i].Y.ToInvariantString() + separator);
                            }
                Severity: Major
                Found in ChemSharp.Spectroscopy/Export/CSVExporter.cs and 2 other locations - About 45 mins to fix
                ChemSharp.Spectroscopy/Export/CSVExporter.cs on lines 39..43
                ChemSharp.Spectroscopy/Export/CSVExporter.cs on lines 45..49

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

                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