Showing 194 of 198 total issues
Function fromKubeConfigVariable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function fromKubeConfigVariable(string $context = null)
{
/** @var \RenokiCo\PhpK8s\KubernetesCluster $this */
$cluster = new static;
- 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 __call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function __call($method, $parameters)
{
// Proxy the ->get[Resource]ByName($name, $namespace = 'default')
// For example, ->getConfigMapByName('settings')
if (preg_match('/get(.+)ByName/', $method, $matches)) {
- 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 $ws. Configured minimum length is 3. Open
[$loop, $ws] = $this->getWsClient($url);
- 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
Function buildStreamContextOptions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function buildStreamContextOptions(): array
{
$sslOptions = $headers = [];
if (is_bool($this->verify)) {
- 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
Terminating statement must be on a line by itself Open
case static::ATTACH_OP: return $this->attachPath($path, $payload, $query);
- Exclude checks
The DEFAULT body must start on the line following the statement Open
default: break;
- Exclude checks
The CASE body must start on the line following the statement Open
case static::WATCH_LOGS_OP: return $this->watchLogsPath($path, $payload, $query);
- Exclude checks
Terminating statement must be on a line by itself Open
default: break;
- Exclude checks
Terminating statement must be on a line by itself Open
case static::WATCH_LOGS_OP: return $this->watchLogsPath($path, $payload, $query);
- Exclude checks
Function addLabelSelectorRequirement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addLabelSelectorRequirement(array $expressions, array $fieldsExpressions, string $topologyKey)
{
foreach ($expressions as &$expression) {
if ($expression instanceof Expression) {
$expression = $expression->toArray();
- 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
The CASE body must start on the line following the statement Open
case static::WATCH_OP: return $this->watchPath($path, $payload, $query);
- Exclude checks
Terminating statement must be on a line by itself Open
case static::WATCH_OP: return $this->watchPath($path, $payload, $query);
- Exclude checks
Function addNodeSelectorPreference
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addNodeSelectorPreference(array $expressions, array $fieldsExpressions, int $weight = 1)
{
foreach ($expressions as &$expression) {
if ($expression instanceof Expression) {
$expression = $expression->toArray();
- 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 addNodeRequirement
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addNodeRequirement(array $expressions, array $fieldsExpressions)
{
foreach ($expressions as &$expression) {
if ($expression instanceof Expression) {
$expression = $expression->toArray();
- 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
The CASE body must start on the line following the statement Open
case static::ATTACH_OP: return $this->attachPath($path, $payload, $query);
- Exclude checks
Function addPreference
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addPreference(array $expressions, array $fieldsExpressions, int $weight = 1)
{
foreach ($expressions as &$expression) {
if ($expression instanceof Expression) {
$expression = $expression->toArray();
- 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
The CASE body must start on the line following the statement Open
case static::EXEC_OP: return $this->execPath($path, $query);
- Exclude checks
Terminating statement must be on a line by itself Open
case static::EXEC_OP: return $this->execPath($path, $query);
- Exclude checks
The method allResourcesPath has a boolean flag argument $withNamespace, which is a certain sign of a Single Responsibility Principle violation. Open
public function allResourcesPath(bool $withNamespace = true): string
- 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 getInitContainer has a boolean flag argument $asInstance, which is a certain sign of a Single Responsibility Principle violation. Open
public function getInitContainer(string $containerName, bool $asInstance = 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) {
}
}