arkaitzgarro/elastic-apm-laravel

View on GitHub
src/Collectors/DBQueryCollector.php

Summary

Maintainability
A
1 hr
Test Coverage
A
95%

Method onQueryExecutedEvent has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function onQueryExecutedEvent(QueryExecuted $query): void
    {
        if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
            if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
                return;
Severity: Minor
Found in src/Collectors/DBQueryCollector.php - About 1 hr to fix

    Avoid using static access to class '\Jasny\DB\MySQL\QuerySplitter' in method 'getQueryName'.
    Open

                $tables = QuerySplitter::splitTables($sql);
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.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

    Avoid using static access to class '\Jasny\DB\MySQL\QuerySplitter' in method 'getQueryName'.
    Open

                $query_type = QuerySplitter::getQueryType($sql);
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.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

    Merge this if statement with the enclosing one.
    Open

                if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {

    Merging collapsible if statements increases the code's readability.

    Noncompliant Code Example

    if (condition1) {
      if (condition2) {
        ...
      }
    }
    

    Compliant Solution

    if (condition1 && condition2) {
      ...
    }
    

    The variable $start_time is not named in camelCase.
    Open

        private function onQueryExecutedEvent(QueryExecuted $query): void
        {
            if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
                if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
                    return;
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $end_time is not named in camelCase.
    Open

        private function onQueryExecutedEvent(QueryExecuted $query): void
        {
            if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
                if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
                    return;
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $end_time is not named in camelCase.
    Open

        private function onQueryExecutedEvent(QueryExecuted $query): void
        {
            if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
                if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
                    return;
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $query_type is not named in camelCase.
    Open

        private function getQueryName(string $sql): string
        {
            $fallback = 'Eloquent Query';
    
            try {
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $query_type is not named in camelCase.
    Open

        private function getQueryName(string $sql): string
        {
            $fallback = 'Eloquent Query';
    
            try {
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $query_type is not named in camelCase.
    Open

        private function getQueryName(string $sql): string
        {
            $fallback = 'Eloquent Query';
    
            try {
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $start_time is not named in camelCase.
    Open

        private function onQueryExecutedEvent(QueryExecuted $query): void
        {
            if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
                if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
                    return;
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $start_time is not named in camelCase.
    Open

        private function onQueryExecutedEvent(QueryExecuted $query): void
        {
            if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
                if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
                    return;
    Severity: Minor
    Found in src/Collectors/DBQueryCollector.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status