lightster/hodor

View on GitHub

Showing 36 of 36 total issues

Avoid too many return statements within this method.
Open

                return $container['phpmig.adapter']->getMigrationsPath();
Severity: Major
Found in src/Hodor/Database/Phpmig/Container.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return $buffered_jobs;
Severity: Major
Found in src/Hodor/Database/Adapter/Testing/Superqueuer.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return $db_factory->getAdapter($db_config)->getYoPdo();
Severity: Major
Found in src/Hodor/Database/Phpmig/Container.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return new PgsqlPhpmigAdapter($db_adapter);
Severity: Major
Found in src/Hodor/Database/Phpmig/Container.php - About 30 mins to fix

Avoid assigning values to variables in if clauses and the like (line '139', column '17').
Open

    private function sortBufferedJobs(array $buffered_jobs)
    {
        $compare_jobs = function ($field, array $job_a, array $job_b) {
            if ($job_a[$field] == $job_b[$field]) {
                return 0;

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

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

Avoid unused parameters such as '$output'.
Open

    protected function execute(InputInterface $input, OutputInterface $output)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused private methods such as 'validateQueueName'.
Open

    private function validateQueueName(array $options)
    {
        if ($this->worker_config->hasWorkerConfig("worker", $options['queue_name'])) {
            return;
        }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

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

        } else {
            throw new Exception(
                "Config could not be found or generated by JobQueueFacade."
            );
        }
Severity: Minor
Found in src/Hodor/JobQueue/JobQueue.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 execute uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $manager->setupDaemon();
        }

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

Avoid unused parameters such as '$buffered_job_id'.
Open

    public function __construct($message, $buffered_job_id, array $meta)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused private methods such as 'validateRunAfter'.
Open

    private function validateRunAfter(array $options)
    {
        if ($options['run_after'] instanceof DateTime) {
            return;
        }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid unused parameters such as '$meta'.
Open

    public function __construct($message, $buffered_job_id, array $meta)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid unused private methods such as 'validateMutexId'.
Open

    private function validateMutexId(array $options)
    {
        if (is_scalar($options['mutex_id']) && strlen("{$options['mutex_id']}") >= 1) {
            return;
        }

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Avoid using static access to class '\Hodor\Config\LoaderFacade' in method 'execute'.
Open

        $config = Config::loadFromFile($input->getArgument('hodor-config'));

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 unused local variables such as '$option_value'.
Open

        foreach ($options as $option_name => $option_value) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid unused private methods such as 'validateJobRank'.
Open

    private function validateJobRank(array $options)
    {
        if (is_int($options['job_rank'])
            && -20 <= $options['job_rank'] && $options['job_rank'] <= 19
        ) {

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Severity
Category
Status
Source
Language