H4MSK1/anax-weather

View on GitHub

Showing 5 of 29 total issues

Function processRequest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function processRequest($iplocation, $coords, $type, Api $curl)
    {
        $payload = ['weather' => [], 'map' => null];
        $lat = 0;
        $lng = 0;
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 normalizeForecast has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function normalizeForecast($data)
    {
        $newData = [];

        if (array_key_exists('daily', $data)) {
Severity: Minor
Found in src/Curl/Traits/WeatherApiTrait.php - About 1 hr to fix

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

        public function processRequest($iplocation, $coords, $type, Api $curl)
        {
            $payload = ['weather' => [], 'map' => null];
            $lat = 0;
            $lng = 0;
    Severity: Minor
    Found in src/Weather/Weather.php - About 1 hr to fix

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

          public function fetchWeatherHistory($lat, $lng, $pastDays = 30)
          {
              $service = $this->getServiceByName('darksky');
              $endpoint = "{$service['endpoint']}{$service['key']}/{$lat},{$lng},{{day}}?lang=sv&units=si";
      
      
      Severity: Minor
      Found in src/Curl/Traits/WeatherApiTrait.php - About 1 hr to fix

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

            public function normalizeForecast($data)
            {
                $newData = [];
        
                if (array_key_exists('daily', $data)) {
        Severity: Minor
        Found in src/Curl/Traits/WeatherApiTrait.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