Showing 316 of 316 total issues
Function v1Factory
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function v1Factory(string $key, $value, LinkResolver $linkResolver) : void
{
$fragment = null;
switch ($value->type) {
case 'Image':
- 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
Method submit
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function submit() : Response
{
if ($this->form->getMethod() !== 'GET' ||
$this->form->getEnctype() !== 'application/x-www-form-urlencoded' ||
! $this->form->getAction()
Avoid using short method names like Predicates::in(). The configured minimum method name length is 3. Open
public static function in(string $fragment, array $values) : Predicate
{
return new SimplePredicate("in", $fragment, [$values]);
}
- 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 Predicates::gt(). The configured minimum method name length is 3. Open
public static function gt(string $fragment, $upperBound) : Predicate
{
if (! \is_numeric($upperBound)) {
throw new InvalidArgumentException(
'Predicates::gt() expects a number as it’s second argument'
- 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 Predicates::at(). The configured minimum method name length is 3. Open
public static function at(string $fragment, $value) : Predicate
{
return new SimplePredicate("at", $fragment, [$value]);
}
- 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 SimplePredicate::q(). The configured minimum method name length is 3. Open
public function q() : string
{
$query = "[:d = " . $this->name . "(";
if ($this->name === "similar") {
$query .= "\"" . $this->fragment . "\"";
- 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 Predicate::q(). The configured minimum method name length is 3. Open
public function q() : string;
- 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 Predicates::lt(). The configured minimum method name length is 3. Open
public static function lt(string $fragment, $lowerBound) : Predicate
{
if (! \is_numeric($lowerBound)) {
throw new InvalidArgumentException(
'Predicates::lt() expects a number as it’s second argument'
- 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
Method fromJsonObject
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromJsonObject(stdClass $data, Api $api) : DocumentInterface
{
$inst = new static;
$inst->api = $api;
$inst->id = $inst->assertRequiredProperty($data, 'id', false);
Method fromJson
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function fromJson($value, LinkResolver $linkResolver) : self
{
// Type and Label are the same for V1 & V2
$type = isset($value->slice_type)
? (string) $value->slice_type
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
array $refs,
array $bookmarks,
array $types,
array $tags,
array $forms,
Function set
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function set(string $key, $value) : self
{
if (empty($key)) {
throw new Exception\InvalidArgumentException('Form parameter key must be a non-empty string');
}
- 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
Function previewSession
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function previewSession(string $token, string $defaultUrl) : string
{
try {
// $token is untrusted input, possibly from a GET request and will be retrieved by the http client
$token = $this->validatePreviewToken($token);
- 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 variables with short names like $id. Configured minimum length is 3. Open
private $id;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The parameter $oauth_initiate is not named in camelCase. Open
private function __construct(
array $refs,
array $bookmarks,
array $types,
array $tags,
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $b. Configured minimum length is 3. Open
list($r, $g, $b) = sscanf($this->value, "#%02x%02x%02x");
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
private $id;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $e. Configured minimum length is 3. Open
private function invalidRepo(Exception\ExceptionInterface $e)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
private $id;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $g. Configured minimum length is 3. Open
list($r, $g, $b) = sscanf($this->value, "#%02x%02x%02x");
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}