bjorn-87/anax-weathermodule

View on GitHub

Showing 37 of 37 total issues

Method indexActionPost has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function indexActionPost() : array
    {
        $mapUrl = "https://www.openstreetmap.org/search?query=";
        $lat = null;
        $long = null;
Severity: Major
Found in src/Weather/WeatherApiController.php - About 3 hrs to fix

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

        public function indexActionGet() : object
        {
            $title = "Weather";
            $page = $this->di->get("page");
            $lat = null;
    Severity: Minor
    Found in src/Weather/WeatherController.php - About 1 hr to fix

      Method indexActionPost has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function indexActionPost() : array
          {
              $ipAdr = $this->di->request->getPost("ip");
              $mapUrl = "https://www.openstreetmap.org/search?query=";
              $valid = $this->validateIp->validate($ipAdr);
      Severity: Minor
      Found in src/GeoLocation/GeoApiController.php - About 1 hr to fix

        Function indexActionPost has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function indexActionPost() : array
            {
                $mapUrl = "https://www.openstreetmap.org/search?query=";
                $lat = null;
                $long = null;
        Severity: Minor
        Found in src/Weather/WeatherApiController.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 getData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getData(array $weather, string $option = "daily")
            {
                $count = count($weather);
                $selected = [];
        
        
        Severity: Minor
        Found in src/Weather/Weather.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 indexActionPost has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function indexActionPost() : array
            {
                $valid = null;
                $type = null;
                $host = null;
        Severity: Minor
        Found in src/Validate/IpJsonController.php - About 1 hr to fix

          Method getData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getData(array $weather, string $option = "daily")
              {
                  $count = count($weather);
                  $selected = [];
          
          
          Severity: Minor
          Found in src/Weather/Weather.php - About 1 hr to fix

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

                public function indexActionGet() : object
                {
                    $title = "Geolocation";
                    $page = $this->di->get("page");
                    $ipAdr = $this->di->request->getGet("ip");
            Severity: Minor
            Found in src/GeoLocation/GeoLocationController.php - About 1 hr to fix

              Function indexActionPost has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function indexActionPost() : array
                  {
                      $valid = null;
                      $type = null;
                      $host = null;
              Severity: Minor
              Found in src/Validate/IpJsonController.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 indexAction has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function indexAction() : object
                  {
                      $title = "Validate IP";
                      $valid = null;
                      $type = null;
              Severity: Minor
              Found in src/Validate/ValidateIpController.php - About 1 hr to fix

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

                    public function indexAction() : object
                    {
                        $title = "Validate IP";
                        $valid = null;
                        $type = null;
                Severity: Minor
                Found in src/Validate/ValidateIpController.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 multiCurlApi has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function multiCurlApi(array $urls) : array
                    {
                        $response = [];
                
                        if (count($urls) !== 0) {
                Severity: Minor
                Found in src/Curl/Curl.php - About 1 hr to fix

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

                      public function indexActionGet() : object
                      {
                          $title = "Weather";
                          $page = $this->di->get("page");
                          $lat = null;
                  Severity: Minor
                  Found in src/Weather/WeatherController.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 multiCurlApi has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function multiCurlApi(array $urls) : array
                      {
                          $response = [];
                  
                          if (count($urls) !== 0) {
                  Severity: Minor
                  Found in src/Curl/Curl.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

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

                      public function indexActionPost() : array
                      {
                          $ipAdr = $this->di->request->getPost("ip");
                          $mapUrl = "https://www.openstreetmap.org/search?query=";
                          $valid = $this->validateIp->validate($ipAdr);
                  Severity: Minor
                  Found in src/GeoLocation/GeoApiController.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

                  The method validate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  return false;
                              }
                  Severity: Minor
                  Found in src/Validate/ValidateIp.php by phpmd

                  ElseExpression

                  Since: 1.4.0

                  An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($flag) {
                              // one branch
                          } else {
                              // another branch
                          }
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#elseexpression

                  The method indexActionPost uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                          } else {
                              http_response_code(400);
                              $json = [
                                  "error" => [
                                      "status" => http_response_code(),
                  Severity: Minor
                  Found in src/Weather/WeatherApiController.php by phpmd

                  ElseExpression

                  Since: 1.4.0

                  An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($flag) {
                              // one branch
                          } else {
                              // another branch
                          }
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#elseexpression

                  The method indexActionPost uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  $location = $this->weather->getLatLong($search);
                                  $lat = $location["latitude"];
                                  $long = $location["longitude"];
                              }
                  Severity: Minor
                  Found in src/Weather/WeatherApiController.php by phpmd

                  ElseExpression

                  Since: 1.4.0

                  An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($flag) {
                              // one branch
                          } else {
                              // another branch
                          }
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#elseexpression

                  The method getUserIp uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                          } else {
                              $ipAdr = "X.X.X.X";
                          }
                  Severity: Minor
                  Found in src/GeoLocation/GeoLocation.php by phpmd

                  ElseExpression

                  Since: 1.4.0

                  An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($flag) {
                              // one branch
                          } else {
                              // another branch
                          }
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#elseexpression

                  The method indexActionPost uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  $valid = false;
                              }
                  Severity: Minor
                  Found in src/Validate/IpJsonController.php by phpmd

                  ElseExpression

                  Since: 1.4.0

                  An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                  Example

                  class Foo
                  {
                      public function bar($flag)
                      {
                          if ($flag) {
                              // one branch
                          } else {
                              // another branch
                          }
                      }
                  }

                  Source https://phpmd.org/rules/cleancode.html#elseexpression

                  Severity
                  Category
                  Status
                  Source
                  Language