samiulhoque/codility-lessons

View on GitHub

Showing 28 of 28 total issues

Function solution has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($S)
    {
        $length = strlen($S);
        $map = [')' => '(', '}' => '{', ']' => '['];
        if ($length) {
Severity: Minor
Found in src/Lesson05/Brackets.php - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function solution has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($A)
    {
        $N = count($A);
        if ($N > 1) {
            $count = array_count_values($A);
Severity: Minor
Found in src/Lesson06/EquiLeader.php - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function solution has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($A, $B)
    {
        $N = count($A);
        $stack = [];
        for ($i = 0; $i < $N; $i++) {
Severity: Minor
Found in src/Lesson05/Fish.php - About 1 hr 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 solution has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($S)
    {
        $length = strlen($S);
        if ($length) {
            $parentheses = [];
Severity: Minor
Found in src/Lesson05/Nesting.php - About 1 hr 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 solution has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($A)
    {
        $arrayCount = count($A);
        $peaks = [];
        for ($i = 1; $i < $arrayCount - 1; $i++) {
Severity: Minor
Found in src/Lesson08/Flags.php - About 1 hr 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 solution has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($N, $A)
    {
        $output = array_fill(0, $N, 0);
        $count = count($A);
        $maximum = 0;
Severity: Minor
Found in src/Lesson02/MaxCounters.php - About 1 hr 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 solution has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($A)
    {
        $N = count($A);
        if ($N <= 2) {
            return 0;
Severity: Minor
Found in src/Lesson08/Peaks.php - About 1 hr 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 getNegatives has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function getNegatives($A, $allPositives)
    {
        $arrayCount = count($A);
        $allNegatives = [];
        $twoNegatives = [];
Severity: Minor
Found in src/Lesson04/MaxProductOfThree.php - About 1 hr 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 solution has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($A)
    {
        $uniquePositives = array_unique(array_filter($A, function ($number) {
            return $number > 0;
        }));
Severity: Minor
Found in src/Lesson02/MissingInteger.php - About 1 hr 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 solution has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function solution($A)
    {
        sort($A);
        $allPositives = $this->getPositives($A);
        list($allNegatives, $twoNegatives) = $this->getNegatives($A, $allPositives);
Severity: Minor
Found in src/Lesson04/MaxProductOfThree.php - About 1 hr 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 solution has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function solution($A)
    {
        $N = count($A);
        if ($N <= 2) {
            return 0;
Severity: Minor
Found in src/Lesson08/Peaks.php - About 1 hr to fix

    Method solution has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function solution($A)
        {
            $N = count($A);
            if ($N > 1) {
                $count = array_count_values($A);
    Severity: Minor
    Found in src/Lesson06/EquiLeader.php - About 1 hr to fix

      Function solution has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function solution($S, $P, $Q)
          {
              $queries = count($P);
              $output = [];
              for ($i = 0; $i < $queries; $i++) {
      Severity: Minor
      Found in src/Lesson03/GenomicRangeQuery.php - About 1 hr 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 solution has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function solution($N, $P, $Q)
          {
              $initialArrayCount = count($P);
              $primes = array_values($this->filterPrimes($N, $this->getPrimes($N)));
              $primeCount = count($primes);
      Severity: Minor
      Found in src/Lesson09/CountSemiprimes.php - About 1 hr to fix

        Function solution has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function solution($A)
            {
                $N = count($A);
                $maxProfit = 0;
                if ($N) {
        Severity: Minor
        Found in src/Lesson07/MaxProfit.php - About 55 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

        Function solution has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function solution($A)
            {
                $position = 0;
                $count = count($A);
                $minAvg = ($A[0] + $A[1]) / 2;
        Severity: Minor
        Found in src/Lesson03/MinAvgTwoSlice.php - About 45 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

        Function getSemiPrimes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getSemiPrimes($N, $primeCount, $primes)
            {
                $semiPrimes = [];
                for ($i = 0; $i < $primeCount; $i++) {
                    for ($j = $i; $j < $primeCount; $j++) {
        Severity: Minor
        Found in src/Lesson09/CountSemiprimes.php - About 45 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

        Function getKey has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getKey($value, $semiPrimes, $range)
            {
                $key = null;
                if (array_key_exists($value, $semiPrimes)) {
                    $key = $value;
        Severity: Minor
        Found in src/Lesson09/CountSemiprimes.php - About 45 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

        Function solution has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function solution($A)
            {
                $N = count($A);
                $countValues = array_count_values($A);
                $occurrences = array_fill(0, $N * 2 + 1, 0);
        Severity: Minor
        Found in src/Lesson09/CountNonDivisible.php - About 45 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

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

            public function solution($A)
            {
                $count = count($A);
                $sum = 0;
                $total = 0;
        Severity: Minor
        Found in src/Lesson03/PassingCars.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language