Showing 67 of 67 total issues
The class Pins has 17 public methods. Consider refactoring Pins to keep number of public methods under 10. Open
class Pins extends EntityProvider
{
use Searchable,
CanBeDeleted,
SendsMessages,
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Pinners has 11 public methods. Consider refactoring Pinners to keep number of public methods under 10. Open
class Pinners extends FollowableProvider
{
use Searchable, ResolvesCurrentUser;
/**
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
CurlHttpClient
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class CurlHttpClient implements HttpClient
{
/**
* Custom CURL options for requests.
*
Request
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Request
{
const DEFAULT_TOKEN = '1234';
/**
Avoid excessively long variable names like $nameWithRemovedSpaces. Keep variable name length under 20. Open
$nameWithRemovedSpaces = str_replace(' ', '-', $board);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $methodsThatRequireLogin. Keep variable name length under 20. Open
$methodsThatRequireLogin = array_merge($this->loginRequiredFor, $this->requiresLoginFor());
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Function processCallback
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function processCallback()
{
$this->resultsNum = 0;
$this->processed = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid using short method names like User::id(). The configured minimum method name length is 3. Open
public function id()
{
return $this->getProfileData('id');
}
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
Avoid using short method names like Boards::my(). The configured minimum method name length is 3. Open
public function my()
{
return $this->forMe();
}
- Read upRead up
- Exclude checks
ShortMethodName
Since: 0.2
Detects when very short method names are used.
Example
class ShortMethod {
public function a( $index ) { // Violation
}
}
Source https://phpmd.org/rules/naming.html#shortmethodname
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 36 and the first side effect is on line 3. Open
<?php
- Exclude checks
Method edit
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function edit($pindId, $description = '', $link = '', $boardId = null, $title = '', $sectionId = null)
Method create
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function create($imageUrl, $boardId, $description = '', $link = '', $title = '', $sectionId = null)
Method getRegistrationForm
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function getRegistrationForm($email, $password, $name, $country, $age)
Method fillRegistrationForm
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function fillRegistrationForm($registrationForm, $password, $name, $country, $age)
Method register
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function register($email, $password = null, $name = null, $country = 'GB', $age = 18)
The method login has a boolean flag argument $autoLogin, which is a certain sign of a Single Responsibility Principle violation. Open
public function login($username, $password, $autoLogin = true)
- Read upRead up
- Exclude checks
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
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)
- Read upRead up
- Exclude checks
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
The method deleteInvite has a boolean flag argument $ban, which is a certain sign of a Single Responsibility Principle violation. Open
public function deleteInvite($boardId, $userId, $ban = false)
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '232', column '32'). Open
$data['context'] = new \stdClass();
- Read upRead up
- Exclude checks
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 post has a boolean flag argument $returnData, which is a certain sign of a Single Responsibility Principle violation. Open
public function post($resourceUrl, array $requestOptions = [], $returnData = false)
- Read upRead up
- Exclude checks
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) {
}
}