attogram/shared-media-sandbox

View on GitHub

Showing 15 of 15 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace Attogram\SharedMedia\Sandbox;

use PHPUnit\Framework\TestCase;
Severity: Major
Found in tests/SandboxTest.php and 1 other location - About 3 hrs to fix
tests/BaseTest.php on lines 1..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 91.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<?php

namespace Attogram\SharedMedia\Sandbox;

use PHPUnit\Framework\TestCase;
Severity: Major
Found in tests/BaseTest.php and 1 other location - About 3 hrs to fix
tests/SandboxTest.php on lines 1..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 91.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Missing class import via use statement (line '25', column '21').
Open

        $base = new \Attogram\SharedMedia\Sandbox\Base();
Severity: Minor
Found in tests/BaseTest.php by phpmd

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 '115', column '29').
Open

            $refClass = new \ReflectionClass($class);
Severity: Minor
Found in src/Base.php by phpmd

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 '25', column '24').
Open

        $sandbox = new \Attogram\SharedMedia\Sandbox\Sandbox();
Severity: Minor
Found in tests/SandboxTest.php by phpmd

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

The 'getClass()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    protected function getClass()
    {
        $classNames = array_unique(array_column($this->methods, '0'));
        if (!in_array($this->class, $classNames)) {
            $this->logger->critical('getClass: Class Denied:', [$this->class]);
Severity: Minor
Found in src/Sandbox.php by phpmd

BooleanGetMethodName

Since: 0.2

Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

Example

class Foo {
    /**
     * @return boolean
     */
    public function getFoo() {} // bad
    /**
     * @return bool
     */
    public function isFoo(); // ok
    /**
     * @return boolean
     */
    public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}

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

Suspicious type null of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

            $form .= '<br />' . $this->action[2]
Severity: Minor
Found in src/Sandbox.php by phan

Returning type object but getClass() is declared to return bool
Open

        return new $this->class($this->logger);
Severity: Minor
Found in src/Sandbox.php by phan

Invalid offset 2 of array type array{}
Open

            $form .= '<br />' . $this->action[2]
Severity: Minor
Found in src/Sandbox.php by phan

Argument 1 (object) is bool but \get_class() takes object
Open

        $this->logger->debug('SANDBOX: class: '.get_class($class));
Severity: Minor
Found in src/Sandbox.php by phan

Invalid offset 2 of array type array{}
Open

        if (isset($this->action[2]) && $this->action[2]) { // Requires argument
Severity: Minor
Found in src/Sandbox.php by phan

Call to method format on non-class type string
Open

                    $response = $class->format($results);
Severity: Critical
Found in src/Sandbox.php by phan

Invalid offset 3 of array type array{}
Open

        if (isset($this->action[3]) && $this->action[3]) { // Requires Identifier
Severity: Minor
Found in src/Sandbox.php by phan

Suspicious type void of a variable or expression used to build a string. (Expected type to be able to cast to a string)
Open

                $response = '<pre>' . var_dump($results) . '</pre>';
Severity: Minor
Found in src/Sandbox.php by phan

Cannot assign void return value
Open

                $response = var_dump($results);
Severity: Info
Found in src/Sandbox.php by phan
Severity
Category
Status
Source
Language