Showing 4,939 of 4,939 total issues
The method exit() contains an exit expression. Open
exit($exit_code);
- Read upRead up
- Exclude checks
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
The method accept() has an NPath complexity of 792. The configured NPath complexity threshold is 200. Open
public static function accept(CodeBase $code_base, Closure $file_path_lister, Responder $responder, bool $fork): ?Request
{
FileCache::clear();
$request = $responder->getRequestData();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method visitArray() has an NPath complexity of 1345. The configured NPath complexity threshold is 200. Open
public function visitArray(Node $node): UnionType
{
$children = $node->children;
if (\count($children) > 0) {
$key_set = $this->getEquivalentArraySet($node);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method createPhanSettingsForComposerSettings() has 158 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public static function createPhanSettingsForComposerSettings(array $composer_settings, ?string $vendor_path, array $opts): InitializedSettings
{
$level = $opts['init-level'] ?? 3;
$level = self::LEVEL_MAP[\strtolower((string)$level)] ?? $level;
if (\filter_var($level, FILTER_VALIDATE_INT) === false) {
- Exclude checks
The method resolveDocCommentForClosure() has an NPath complexity of 70682. The configured NPath complexity threshold is 200. Open
private static function resolveDocCommentForClosure(PhpParser\Node\Expression $node): ?string
{
$doc_comment = $node->getDocCommentText();
if (\Phan\Library\StringUtil::isNonZeroLengthString($doc_comment)) {
return $doc_comment;
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method functionLikeFQSENListFromNode() has an NPath complexity of 420. The configured NPath complexity threshold is 200. Open
private function functionLikeFQSENListFromNode($node): array
{
$orig_node = $node;
if ($node instanceof Node) {
$node = (new ContextNode($this->code_base, $this->context, $node))->getEquivalentPHPValue();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getConfigErrors() has 234 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public static function getConfigErrors(array $configuration): array
{
/**
* @param mixed $value
*/
- Exclude checks
The method methodFQSENListFromParts() has an NPath complexity of 672. The configured NPath complexity threshold is 200. Open
private function methodFQSENListFromParts($class_or_expr, $method_name): array
{
$code_base = $this->code_base;
$context = $this->context;
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getPrinter() contains an exit expression. Open
exit(0);
- Read upRead up
- Exclude checks
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
The method visitVar() has 121 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function visitVar(Node $node): UnionType
{
// $$var or ${...} (whose idea was that anyway?)
$name_node = $node->children['name'];
if (($name_node instanceof Node)) {
- Exclude checks
The method analyzeProp() has an NPath complexity of 1926. The configured NPath complexity threshold is 200. Open
private function analyzeProp(Node $node, bool $is_static): UnionType
{
// Either expr(instance) or class(static) is set
$expr_node = $node->children['expr'] ?? null;
try {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
Avoid using empty try-catch blocks in visitMethodCall. Open
} catch (RecursionDepthException $_) {
}
- Read upRead up
- Exclude checks
EmptyCatchBlock
Since: 2.7.0
Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.
Example
class Foo {
public function bar()
{
try {
// ...
} catch (Exception $e) {} // empty catch block
}
}
Source https://phpmd.org/rules/design.html#emptycatchblock
The method unionTypeFromClassNode() has an NPath complexity of 1020. The configured NPath complexity threshold is 200. Open
public static function unionTypeFromClassNode(
CodeBase $code_base,
Context $context,
$node
): UnionType {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method hasInternalFunctionWithFQSEN() has an NPath complexity of 610. The configured NPath complexity threshold is 200. Open
private function hasInternalFunctionWithFQSEN(
FullyQualifiedFunctionName $fqsen
): bool {
$canonical_fqsen = $fqsen->withAlternateId(0);
$found = isset($this->internal_function_fqsen_set[$canonical_fqsen]);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method initHandleMap() has 1161 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected static function initHandleMap(): array
{
$closures = [
/** @return ?ast\Node */
'Microsoft\PhpParser\Node\SourceFileNode' => static function (PhpParser\Node\SourceFileNode $n, int $start_line): ?\ast\Node {
- Exclude checks
The method visitConditional() has an NPath complexity of 18306. The configured NPath complexity threshold is 200. Open
public function visitConditional(Node $node): UnionType
{
$cond_node = $node->children['cond'];
$cond_truthiness = self::checkCondUnconditionalTruthiness($cond_node);
// For the shorthand $a ?: $b, the cond node will be the truthy value.
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getConfigErrors() has an NPath complexity of 933120. The configured NPath complexity threshold is 200. Open
public static function getConfigErrors(array $configuration): array
{
/**
* @param mixed $value
*/
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method phpParserUnionTypeToAstNode() has an NPath complexity of 210. The configured NPath complexity threshold is 200. Open
protected static function phpParserUnionTypeToAstNode($type, ?PhpParser\Node\DelimitedList\QualifiedNameList $other_types, int $line): ?\ast\Node
{
$types = [];
if (!\is_null($type) && !($type instanceof Token && $type->kind === TokenKind::BarToken)) {
$result = static::phpParserTypeToAstNode($type, $line);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method visitConditional() has 142 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function visitConditional(Node $node): UnionType
{
$cond_node = $node->children['cond'];
$cond_truthiness = self::checkCondUnconditionalTruthiness($cond_node);
// For the shorthand $a ?: $b, the cond node will be the truthy value.
- Exclude checks
The method resolveArrayShapeElementTypes() has an NPath complexity of 3752. The configured NPath complexity threshold is 200. Open
private function resolveArrayShapeElementTypes(Node $node, UnionType $union_type): ?UnionType
{
$dim_node = $node->children['dim'];
$dim_value = $dim_node instanceof Node ? (new ContextNode($this->code_base, $this->context, $dim_node))->getEquivalentPHPScalarValue() : $dim_node;
// TODO: detect and warn about null
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}