lifekent/elasticsearch-time-series

View on GitHub

Showing 11 of 11 total issues

Avoid using short method names like AbstractBase::to(). The configured minimum method name length is 3.
Open

    public function to($to)
    {
        $this->storage->to = $to;
    }

ShortMethodName

Since: 0.2

Detects when very short method names are used.

Example

class ShortMethod {
    public function a( $index ) { // Violation
    }
}

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

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

    public function histogram($event, $interval): array
    {
        $this->addParam('type', $event);

        $this->refresh();
Severity: Minor
Found in app/Services/Stats/Storage/ElasticSearch.php - About 1 hr to fix

    Remove error control operator '@' on line 27.
    Open

        public function prepare()
        {
            $this->fields['session'] = @ $this->fields['session'] ?: uniqid();
    
            return $this->fields;
    Severity: Minor
    Found in app/Services/Stats/Event.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Missing class import via use statement (line '22', column '19').
    Open

            $es = new \Stats\Storage\ElasticSearch;

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '18', column '14').
    Open

            return new \Stats\Storage\ElasticSearch($type);

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '58', column '27').
    Open

                $report = new \Stats\Report\Histogram;

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '53', column '27').
    Open

                $report = new \Stats\Report\Count;

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '50', column '27').
    Open

                $logger = new \Stats\Logger;

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

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

        public function histogram($event, $interval): array
        {
            $this->addParam('type', $event);
    
            $this->refresh();
    Severity: Minor
    Found in app/Services/Stats/Storage/ElasticSearch.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

    Avoid using static access to class '\Stats\Storage\Factory' in method '__construct'.
    Open

            $this->storage = \Stats\Storage\Factory::make();

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\Stats\Storage\Factory' in method '__construct'.
    Open

            $this->strg = $strg ?: \Stats\Storage\Factory::make();
    Severity: Minor
    Found in app/Services/Stats/Logger.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Severity
    Category
    Status
    Source
    Language