seregazhuk/php-pinterest-bot

View on GitHub

Showing 67 of 67 total issues

Missing class import via use statement (line '229', column '39').
Open

            $data = ['options' => new \stdClass()];
Severity: Minor
Found in src/Api/Request.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 method getClientInfo has a boolean flag argument $reload, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function getClientInfo($reload = false)
Severity: Minor
Found in src/Api/ProvidersContainer.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Avoid using static access to class '\seregazhuk\PinterestBot\Helpers\UrlBuilder' in method 'exec'.
Open

        $url = UrlBuilder::buildApiUrl($resourceUrl);
Severity: Minor
Found in src/Api/Request.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 assigning values to variables in if clauses and the like (line '186', column '13').
Open

    public function getPaginationData()
    {
        if ($this->hasErrors()) {
            return [];
        }
Severity: Minor
Found in src/Api/Response.php by phpmd

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 using static access to class '\seregazhuk\PinterestBot\Helpers\FileHelper' in method 'buildFilePostData'.
Open

        $data .= 'Content-Type: ' . FileHelper::getMimeType($this->filePathToUpload) . "\r\n\r\n";
Severity: Minor
Found in src/Api/Request.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 assigning values to variables in if clauses and the like (line '49', column '17').
Open

    public function fill($file)
    {
        $this->cookies = [];

        foreach (file($file) as $line) {
Severity: Minor
Found in src/Helpers/Cookies.php by phpmd

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 '$pinId'.
Open

    public function delete($pinId, $commentId)
Severity: Minor
Found in src/Api/Providers/Comments.php by phpmd

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 using static access to class '\seregazhuk\PinterestBot\Helpers\UrlBuilder' in method 'following'.
Open

        $followingUrl = UrlBuilder::getFollowingUrlByType($type);
Severity: Minor
Found in src/Api/Providers/Pinners.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 unused local variables such as '$twitterChannel'.
Open

        return $this->share($pinId, $twitterChannel = 9);
Severity: Minor
Found in src/Api/Traits/CanBeShared.php by phpmd

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 assigning values to variables in if clauses and the like (line '120', column '47').
Open

    protected function requiresLoginFor()
    {
        $loginRequired = [];

        foreach (class_parents($this) + class_uses_recursive($this) as $traitOrParent) {
Severity: Minor
Found in src/Api/Providers/Core/Provider.php by phpmd

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 using static access to class '\seregazhuk\PinterestBot\Helpers\UrlBuilder' in method 'createQuery'.
Open

        return UrlBuilder::buildRequestString($request);
Severity: Minor
Found in src/Api/Request.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 assigning values to variables in if clauses and the like (line '247', column '13').
Open

    protected function setTokenFromCookies()
    {
        if ($token = $this->httpClient->cookie('csrftoken')) {
            $this->csrfToken = $token;
        }
Severity: Minor
Found in src/Api/Request.php by phpmd

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

The function getImage() contains an exit expression.
Open

        die();

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

Avoid using static access to class '\seregazhuk\PinterestBot\Helpers\FileHelper' in method 'saveOriginalImage'.
Open

        FileHelper::saveTo($originalUrl, $destination);
Severity: Minor
Found in src/Api/Providers/Pins.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 unused parameters such as '$key'.
Open

    public function getResponseData($key = null)
Severity: Minor
Found in src/Api/SearchResponse.php by phpmd

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

Only one argument is allowed per line in a multi-line function call
Open

            ], $attributes
Severity: Minor
Found in src/Api/Providers/Boards.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            $email, $password, $name, $country, $age
Severity: Minor
Found in src/Api/Providers/Auth.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            UrlBuilder::RESOURCE_BLOCK_USER, ['blocked_user_id' => $userId]

Only one argument is allowed per line in a multi-line function call
Open

            $requestOptions, $this->response->getBookmarks()

Only one argument is allowed per line in a multi-line function call
Open

            $requestId, UrlBuilder::RESOURCE_CONTACT_REQUEST_ACCEPT
Severity: Minor
Found in src/Api/Providers/Inbox.php by phpcodesniffer
Severity
Category
Status
Source
Language