juliangut/gps

View on GitHub

Showing 5 of 5 total issues

Function exports has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
Severity: Major
Found in Gruntfile.js - About 2 hrs to fix

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

        protected function setCoordinate($value, $coordinate = Gps::LATITUDE)
        {
            if (preg_match('!^' . $this->decimalDegreesFormat . '$!', $value, $matches)) {
                $result = floatval($matches[0]);
            } elseif (preg_match('!^' . $this->decimalMinutesFormat . '$!', $value, $matches)) {
    Severity: Minor
    Found in src/Point.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 normalizeParameterCoordinates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function normalizeParameterCoordinates(array $coordinates)
        {
            if (count($coordinates) == 0 || count($coordinates) > 2) {
                throw new \InvalidArgumentException('Invalid number of arguments');
            }
    Severity: Minor
    Found in src/Point.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

    Consider simplifying this complex logical expression.
    Open

            if ((preg_match('!^' . $this->decimalDegreesFormat . '$!', $coordinates[0])
                && !preg_match('!^' . $this->decimalDegreesFormat . '$!', $coordinates[1]))
                || (preg_match('!^' . $this->decimalMinutesFormat . '$!', $coordinates[0])
                && !preg_match('!^' . $this->decimalMinutesFormat . '$!', $coordinates[0]))
                || (preg_match('!^' . $this->degreesMinutesSecondsFormat . '$!', $coordinates[0])
    Severity: Major
    Found in src/Point.php - About 40 mins to fix

      Function set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function set()
          {
              $coordinates = $this->normalizeParameterCoordinates(array_slice(func_get_args(), 0, 2));
      
              if ((preg_match('!^' . $this->decimalDegreesFormat . '$!', $coordinates[0])
      Severity: Minor
      Found in src/Point.php - 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

      Severity
      Category
      Status
      Source
      Language