H4MSK1/anax-weather

View on GitHub

Showing 29 of 29 total issues

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

            } else {
                $payload['error'] = 'Coordinates not valid';
            }
Severity: Minor
Found in src/Weather/Weather.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 processRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $payload['error'] = 'Ip not valid';
            }
Severity: Minor
Found in src/Weather/Weather.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 processRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            if (strpos($coords, ',') !== false) {
                list($lat, $lng) = explode(',', $coords);
            } else {
                $payload['error'] = 'Coordinates not valid';
Severity: Minor
Found in src/Weather/Weather.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

Line exceeds 120 characters; contains 132 characters
Open

<p>Test: <a href="<?= url('weather/api/forecast?type=forecast&ip=8.8.8.8') ?>">weather/api/forecast?type=forecast&ip=8.8.8.8</a></p>
Severity: Minor
Found in view/anax/weather/api.php by phpcodesniffer

Line exceeds 120 characters; contains 140 characters
Open

            "summary": "Molnigt under dagen och m\u00e5ttlig vind som startar under eftermiddagen, forts\u00e4tter fram till kv\u00e4llen.",
Severity: Minor
Found in view/anax/weather/api.php by phpcodesniffer

Line exceeds 120 characters; contains 166 characters
Open

<p>Test: <a href="<?= url('weather/api/forecast?type=forecast&coords=56.188784,15.5902514') ?>">weather/api/forecast?type=forecast&coords=56.188784,15.5902514</a></p>
Severity: Minor
Found in view/anax/weather/api.php by phpcodesniffer

Line exceeds 120 characters; contains 123 characters
Open

        "start" => "\n\n\n" . t("Revision history") . " {#revision}\n-------------\n\n<span class=\"revision-history\">\n",
Severity: Minor
Found in config/content.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

                } else if (defined("ANAX_PRODUCTION")) {
Severity: Minor
Found in config/di/router.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

        } else if (filter_var($ipAddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
Severity
Category
Status
Source
Language