src/main/java/com/trickl/selection/Selection.java

Summary

Maintainability
F
1 wk
Test Coverage

File Selection.java has 345 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.trickl.selection;

import com.trickl.sort.NaturalOrderingComparator;
import java.lang.reflect.Array;
import java.util.Collection;
Severity: Minor
Found in src/main/java/com/trickl/selection/Selection.java - About 4 hrs to fix

    Method selectLast has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      public static int[] selectLast(
          float[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectLast has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      public static int[] selectLast(
          int[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectLast has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      public static int[] selectLast(
          char[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectLast has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      public static int[] selectLast(
          short[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectLast has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      public static int[] selectLast(
          double[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      public static <T> int[] selectFirst(
          T[] S, int[] freq, int k, Comparator<T> comparator, SelectionAlgorithm selectionAlgorithm) {
        if (comparator == null) comparator = naturalOrderingComparator;
        int[] results = new int[k];
        if (k > 0) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      public static <T> int[] selectFirst(
          char[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          if (k == 1) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      public static <T> int[] selectFirst(
          double[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          if (k == 1) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      public static <T> int[] selectFirst(
          short[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          if (k == 1) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      public static <T> int[] selectFirst(
          float[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          if (k == 1) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      public static <T> int[] selectFirst(
          int[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
        int[] results = new int[k];
        if (k > 0) {
          if (k == 1) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - 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

    Method selectFirst has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          T[] S, int[] freq, int k, Comparator<T> comparator, SelectionAlgorithm selectionAlgorithm) {
    Severity: Minor
    Found in src/main/java/com/trickl/selection/Selection.java - About 35 mins to fix

      Method selectLast has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            T[] S,
            int[] freq,
            int k,
            final Comparator<T> comparator,
            SelectionAlgorithm selectionAlgorithm) {
      Severity: Minor
      Found in src/main/java/com/trickl/selection/Selection.java - About 35 mins to fix

        Method toArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          private static <T> int[] toArray(T[] S, Map<T, Integer> freq) {
            int[] freqArray = new int[S.length];
            if (freq != null) {
              for (int i = 0; i < freqArray.length; ++i) {
                Integer f = freq.get(S[i]);
        Severity: Minor
        Found in src/main/java/com/trickl/selection/Selection.java - 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

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

          public static int[] selectLast(
              double[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 4 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 32..64
        src/main/java/com/trickl/selection/Selection.java on lines 75..107
        src/main/java/com/trickl/selection/Selection.java on lines 118..150
        src/main/java/com/trickl/selection/Selection.java on lines 204..236

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

        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 5 locations. Consider refactoring.
        Open

          public static int[] selectLast(
              char[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 4 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 75..107
        src/main/java/com/trickl/selection/Selection.java on lines 118..150
        src/main/java/com/trickl/selection/Selection.java on lines 161..193
        src/main/java/com/trickl/selection/Selection.java on lines 204..236

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

        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 5 locations. Consider refactoring.
        Open

          public static int[] selectLast(
              int[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 4 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 32..64
        src/main/java/com/trickl/selection/Selection.java on lines 75..107
        src/main/java/com/trickl/selection/Selection.java on lines 161..193
        src/main/java/com/trickl/selection/Selection.java on lines 204..236

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

        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 5 locations. Consider refactoring.
        Open

          public static int[] selectLast(
              float[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 4 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 32..64
        src/main/java/com/trickl/selection/Selection.java on lines 75..107
        src/main/java/com/trickl/selection/Selection.java on lines 118..150
        src/main/java/com/trickl/selection/Selection.java on lines 161..193

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

        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 5 locations. Consider refactoring.
        Open

          public static int[] selectLast(
              short[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              int size = freq == null ? S.length : accumulate(freq, 0, freq.length);
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 4 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 32..64
        src/main/java/com/trickl/selection/Selection.java on lines 118..150
        src/main/java/com/trickl/selection/Selection.java on lines 161..193
        src/main/java/com/trickl/selection/Selection.java on lines 204..236

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

        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 5 locations. Consider refactoring.
        Open

          public static <T> int[] selectFirst(
              double[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              if (k == 1) {
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 3 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 268..299
        src/main/java/com/trickl/selection/Selection.java on lines 311..342
        src/main/java/com/trickl/selection/Selection.java on lines 397..428
        src/main/java/com/trickl/selection/Selection.java on lines 440..471

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

        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 5 locations. Consider refactoring.
        Open

          public static <T> int[] selectFirst(
              float[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              if (k == 1) {
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 3 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 268..299
        src/main/java/com/trickl/selection/Selection.java on lines 311..342
        src/main/java/com/trickl/selection/Selection.java on lines 354..385
        src/main/java/com/trickl/selection/Selection.java on lines 440..471

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

        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 5 locations. Consider refactoring.
        Open

          public static <T> int[] selectFirst(
              int[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              if (k == 1) {
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 3 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 268..299
        src/main/java/com/trickl/selection/Selection.java on lines 311..342
        src/main/java/com/trickl/selection/Selection.java on lines 354..385
        src/main/java/com/trickl/selection/Selection.java on lines 397..428

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

        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 5 locations. Consider refactoring.
        Open

          public static <T> int[] selectFirst(
              short[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              if (k == 1) {
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 3 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 268..299
        src/main/java/com/trickl/selection/Selection.java on lines 354..385
        src/main/java/com/trickl/selection/Selection.java on lines 397..428
        src/main/java/com/trickl/selection/Selection.java on lines 440..471

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

        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 5 locations. Consider refactoring.
        Open

          public static <T> int[] selectFirst(
              char[] S, int[] freq, int k, SelectionAlgorithm selectionAlgorithm) {
            int[] results = new int[k];
            if (k > 0) {
              if (k == 1) {
        Severity: Major
        Found in src/main/java/com/trickl/selection/Selection.java and 4 other locations - About 3 hrs to fix
        src/main/java/com/trickl/selection/Selection.java on lines 311..342
        src/main/java/com/trickl/selection/Selection.java on lines 354..385
        src/main/java/com/trickl/selection/Selection.java on lines 397..428
        src/main/java/com/trickl/selection/Selection.java on lines 440..471

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

        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 static int accumulate(int[] S, int start, int end) {
            int sum = 0;
            for (int i = start; i < end; ++i) {
              sum += S[i];
            }
        Severity: Minor
        Found in src/main/java/com/trickl/selection/Selection.java and 1 other location - About 40 mins to fix
        src/main/java/com/trickl/selection/MedianOfMedians.java on lines 648..654

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

        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 (comparator.compare(S[i], S[j]) == 0) {
                    results[results.length - k] = i;
                    k--;
                  }
        Severity: Minor
        Found in src/main/java/com/trickl/selection/Selection.java and 1 other location - About 40 mins to fix
        src/main/java/com/trickl/selection/Selection.java on lines 495..498

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

        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 (comparator.compare(S[i], S[j]) < 0) {
                    results[results.length - k] = i;
                    k--;
                  }
        Severity: Minor
        Found in src/main/java/com/trickl/selection/Selection.java and 1 other location - About 40 mins to fix
        src/main/java/com/trickl/selection/Selection.java on lines 503..506

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

        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