arkaitzgarro/elastic-apm-laravel

View on GitHub
src/Collectors/JobCollector.php

Summary

Maintainability
A
1 hr
Test Coverage
A
98%

Method registerEventListeners has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function registerEventListeners(): void
    {
        $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
            if ($this->app->runningInConsole()) {
                // Since the application starts only once for async queues, make sure
Severity: Minor
Found in src/Collectors/JobCollector.php - About 1 hr to fix

    Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
    Open

        public function registerEventListeners(): void
    Severity: Critical
    Found in src/Collectors/JobCollector.php by sonar-php

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

    Avoid using static access to class '\Illuminate\Support\Facades\Log' in method 'send'.
    Open

                Log::error($exception, ['api_response' => (string) $exception->getResponse()->getBody()]);
    Severity: Minor
    Found in src/Collectors/JobCollector.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 '\Illuminate\Support\Facades\Log' in method 'send'.
    Open

                Log::error($t->getMessage());
    Severity: Minor
    Found in src/Collectors/JobCollector.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

    The parameter $transaction_name is not named in camelCase.
    Open

        protected function stopTransaction(string $transaction_name, int $result): void
        {
            // Stop the transaction and measure the time
            $this->agent->stopTransaction($transaction_name, ['result' => $result]);
            $this->agent->collectEvents($transaction_name);
    Severity: Minor
    Found in src/Collectors/JobCollector.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $transaction_name is not named in camelCase.
    Open

        protected function startTransaction(string $transaction_name): Transaction
        {
            return $this->agent->startTransaction(
                $transaction_name,
                [],
    Severity: Minor
    Found in src/Collectors/JobCollector.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $transaction_name is not named in camelCase.
    Open

        protected function setTransactionType(string $transaction_name): void
        {
            $this->agent->getTransaction($transaction_name)->setMeta([
                'type' => 'job',
            ]);
    Severity: Minor
    Found in src/Collectors/JobCollector.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $transaction_name is not named in camelCase.
    Open

        protected function addMetadata(string $transaction_name, Job $job): void
        {
            $this->agent->getTransaction($transaction_name)->setCustomContext([
                'job_id' => $job->getJobId(),
                'max_tries' => $job->maxTries(),
    Severity: Minor
    Found in src/Collectors/JobCollector.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The variable $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function startTransaction(string $transaction_name): Transaction
        {
            return $this->agent->startTransaction(
                $transaction_name,
                [],
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function stopTransaction(string $transaction_name, int $result): void
        {
            // Stop the transaction and measure the time
            $this->agent->stopTransaction($transaction_name, ['result' => $result]);
            $this->agent->collectEvents($transaction_name);
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function getTransactionName($event): string
        {
            $transaction_name = $event->job->resolveName();
    
            return $this->shouldIgnoreTransaction($transaction_name) ? '' : $transaction_name;
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function setTransactionType(string $transaction_name): void
        {
            $this->agent->getTransaction($transaction_name)->setMeta([
                'type' => 'job',
            ]);
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function getTransactionName($event): string
        {
            $transaction_name = $event->job->resolveName();
    
            return $this->shouldIgnoreTransaction($transaction_name) ? '' : $transaction_name;
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function stopTransaction(string $transaction_name, int $result): void
        {
            // Stop the transaction and measure the time
            $this->agent->stopTransaction($transaction_name, ['result' => $result]);
            $this->agent->collectEvents($transaction_name);
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function addMetadata(string $transaction_name, Job $job): void
        {
            $this->agent->getTransaction($transaction_name)->setCustomContext([
                'job_id' => $job->getJobId(),
                'max_tries' => $job->maxTries(),
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        public function registerEventListeners(): void
        {
            $this->app->events->listen(JobProcessing::class, function (JobProcessing $event) {
                if ($this->app->runningInConsole()) {
                    // Since the application starts only once for async queues, make sure
    Severity: Minor
    Found in src/Collectors/JobCollector.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 $transaction_name is not named in camelCase.
    Open

        protected function getTransactionName($event): string
        {
            $transaction_name = $event->job->resolveName();
    
            return $this->shouldIgnoreTransaction($transaction_name) ? '' : $transaction_name;
    Severity: Minor
    Found in src/Collectors/JobCollector.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