YetiForceCompany/YetiForceCRM

View on GitHub
app/Version.php

Summary

Maintainability
A
0 mins
Test Coverage
B
80%

Suspicious array access to false
Open

        return static::compare($version, static::$versions[$type], $condition);
Severity: Minor
Found in app/Version.php by phan

Suspicious array access to false
Open

        return static::$versions[$type];
Severity: Minor
Found in app/Version.php by phan

Define a constant instead of duplicating this literal "appVersion" 3 times.
Open

    public static function get($type = 'appVersion'): string
Severity: Critical
Found in app/Version.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Avoid variables with short names like $v2. Configured minimum length is 3.
Open

    public static function compare($v1, $v2, $operator = '==')
Severity: Minor
Found in app/Version.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $v1. Configured minimum length is 3.
Open

    public static function compare($v1, $v2, $operator = '==')
Severity: Minor
Found in app/Version.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $type
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            static::$versions = require 'config/version.php';
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return mixed
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    private static function init(): void
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool|int
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $ev2 = \explode('.', $v2);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $lv2 = \count($ev2);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to load versions.
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $type
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check app versions with given version.
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $version   - String Version against which comparision to be done
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    private static $versions = false;
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return static::$versions[$type];
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false === static::$versions) {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        static::init();
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $v2
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $fullVer = \explode('.', self::get($type));
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $v1
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $operator
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $type
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $condition - String Condition like ( '=', '!=', '<', '<=', '>', '>=')
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('x' === substr($v2, -1)) {
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return version_compare($v1, $v2, $operator);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function get($type = 'appVersion'): string
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get current short version of system.
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getShort($type = 'appVersion'): string
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        static::init();
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return \implode('.', $fullVer);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Compares two version number strings.
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            \array_pop($ev2);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function check($version, $type = 'appVersion', $condition = '>=')
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return static::compare($version, static::$versions[$type], $condition);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function compare($v1, $v2, $operator = '==')
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $v2 = \implode('.', $ev2);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get current version of system.
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        array_pop($fullVer);
Severity: Minor
Found in app/Version.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $v1 = \implode('.', \array_slice(\explode('.', $v1), 0, $lv2));
Severity: Minor
Found in app/Version.php by phpcodesniffer

There are no issues that match your filters.

Category
Status