Showing 247 of 250 total issues
Function getColumnContent
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getColumnContent($columnId, IncidentReport $report): string
{
switch ($columnId) {
case 'e_nummer':
$numberString = $report->getNumber();
- 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 add
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function add(CustomType $customType, CustomField $customField)
{
if ($customType instanceof CustomTaxonomy) {
$taxonomy = $customType::getSlug();
- 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 checkPreconditions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function checkPreconditions()
{
$this->fileHasHeadlines = (bool) Utilities::getArrayValueIfKey($this->args, 'has_headlines', false);
$delimiter = Utilities::getArrayValueIfKey($this->args, 'delimiter', false);
- 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 renderPage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function renderPage()
{
echo '<div class="wrap">';
echo '<h1>Einsatzverwaltung</h1>';
- 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 getQuery
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getQuery(): WP_Query
{
// Wähle nur veröffentlichte Einsatzberichte aus
$args = array(
'post_type' => 'einsatz',
- 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 compareVehicles
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function compareVehicles(WP_Term $vehicle1, WP_Term $vehicle2): int
{
$order1 = get_term_meta($vehicle1->term_id, 'vehicleorder', true);
$order2 = get_term_meta($vehicle2->term_id, 'vehicleorder', true);
- 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 addBadgeToMenu
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addBadgeToMenu()
{
global $submenu;
$termsWithParentCount = $this->getTermsWithParentCount();
if ($termsWithParentCount > 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
Function groupVehiclesByUnit
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function groupVehiclesByUnit(array $vehicles): array
{
// Get and sort the units
$units = get_terms(['taxonomy' => Unit::getSlug(), 'hide_empty' => false]);
usort($units, array(Unit::class, 'compare'));
- 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 onPublish
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function onPublish(int $postId, WP_Post $post)
{
$report = new IncidentReport($post);
// Laufende Nummern aktualisieren
- 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 compare
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function compare(WP_Term $unit1, WP_Term $unit2): int
{
$order1 = get_term_meta($unit1->term_id, 'unit_order', true);
$order2 = get_term_meta($unit2->term_id, 'unit_order', true);
- 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 method renderToolPage() has 137 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function renderToolPage()
{
$this->helper = new Helper($this->utilities, $this->data);
$this->helper->metaFields = IncidentReport::getMetaFields();
$this->helper->taxonomies = IncidentReport::getTerms();
- Exclude checks
The 'getStateForReport()' method which returns a boolean should be named 'is...()' or 'has...()' Open
public function getStateForReport(int $postId): bool
{
$get_post_meta = get_post_meta($postId, $this->metaKey, true);
return 1 == $get_post_meta;
}
- Read upRead up
- Exclude checks
BooleanGetMethodName
Since: 0.2
Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
Example
class Foo {
/**
* @return boolean
*/
public function getFoo() {} // bad
/**
* @return bool
*/
public function isFoo(); // ok
/**
* @return boolean
*/
public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}
Source https://phpmd.org/rules/naming.html#booleangetmethodname
The method getInsertArgs() has an NPath complexity of 240. The configured NPath complexity threshold is 200. Open
public function getInsertArgs(ReportInsertObject $reportImportObject)
{
$args = array(
'post_type' => Report::getSlug(),
'post_title' => $reportImportObject->getTitle(),
- 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 create_item() has an NPath complexity of 324. The configured NPath complexity threshold is 200. Open
public function create_item($request) // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps -- overridden method
{
$params = $request->get_params();
$start_date_time = DateTimeImmutable::createFromFormat(DATE_RFC3339, $params['date_start']);
- 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 format() has 110 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private function format(?WP_Post $post, string $pattern, string $tag, $context = 'post'): string
{
if ($post == null && !in_array($tag, $this->tagsNotNeedingPost)) {
return $pattern;
}
- Exclude checks
The method readFile() has an NPath complexity of 456. The configured NPath complexity threshold is 200. Open
private function readFile($numLines = null, $requestedFields = array())
{
$fieldMap = array();
if (!empty($requestedFields)) {
$fields = $this->getFields();
- 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 echoSingleReport() has an NPath complexity of 216. The configured NPath complexity threshold is 200. Open
private function echoSingleReport(IncidentReport $report, $instance)
{
if (true === ($instance['showAnnotations'])) {
$annotationIconBar = AnnotationIconBar::getInstance();
printf('<div class="annotation-icon-bar">%s</div>', $annotationIconBar->render($report->getPostId()));
- 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 doUpdate() has an NPath complexity of 2324522934. The configured NPath complexity threshold is 200. Open
public function doUpdate(int $currentDbVersion, int $targetDbVersion)
{
if (empty($targetDbVersion)) {
return new WP_Error('', 'Zieldatenbankversion darf nicht leer sein');
}
- 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 upgrade180() has an NPath complexity of 222. The configured NPath complexity threshold is 200. Open
public function upgrade180()
{
// Rewrite post_type to evw_legacy_unit
global $wpdb;
$query = $wpdb->prepare("UPDATE $wpdb->posts SET post_type = %s WHERE post_type = %s", 'evw_legacy_unit', 'evw_unit');
- 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 unused private methods such as 'getName'. Open
private function getName($object): string
{
if ($object instanceof WP_Term) {
return $object->name;
} elseif ($object instanceof WP_Post) {
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}