Showing 247 of 250 total issues
File Update.php
has 484 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace abrain\Einsatzverwaltung;
use WP_Error;
use WP_User;
File Formatter.php
has 437 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace abrain\Einsatzverwaltung\Util;
use abrain\Einsatzverwaltung\Frontend\AnnotationIconBar;
use abrain\Einsatzverwaltung\Model\IncidentReport;
Function format
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private function format(?WP_Post $post, string $pattern, string $tag, $context = 'post'): string
{
if ($post == null && !in_array($tag, $this->tagsNotNeedingPost)) {
return $pattern;
}
- 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
File ReportEditScreen.php
has 344 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace abrain\Einsatzverwaltung\Admin;
use abrain\Einsatzverwaltung\Model\IncidentReport;
use abrain\Einsatzverwaltung\Types\IncidentType;
Method renderToolPage
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function renderToolPage()
{
$this->helper = new Helper($this->utilities, $this->data);
$this->helper->metaFields = IncidentReport::getMetaFields();
$this->helper->taxonomies = IncidentReport::getTerms();
Function renderToolPage
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function renderToolPage()
{
$this->helper = new Helper($this->utilities, $this->data);
$this->helper->metaFields = IncidentReport::getMetaFields();
$this->helper->taxonomies = IncidentReport::getTerms();
- 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 format
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function format(?WP_Post $post, string $pattern, string $tag, $context = 'post'): string
{
if ($post == null && !in_array($tag, $this->tagsNotNeedingPost)) {
return $pattern;
}
IncidentReport
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class IncidentReport
{
/**
* Wenn es sich um einen bestehenden Beitrag handelt, ist hier das WordPress-Beitragsobjekt gespeichert.
*
Similar blocks of code found in 2 locations. 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
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 159.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. 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
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 159.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File Helper.php
has 307 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace abrain\Einsatzverwaltung\Import;
use abrain\Einsatzverwaltung\Data;
use abrain\Einsatzverwaltung\Exceptions\ImportException;
The class Renderer has an overall complexity of 71 which is very high. The configured complexity threshold is 50. Open
class Renderer
{
const TABLECLASS = 'einsatzverwaltung-reportlist';
/**
- Exclude checks
The class Report has 12 public methods. Consider refactoring Report to keep number of public methods under 10. Open
class Report extends SubPage
{
private $useReportTemplateOptions = array(
'no' => array(
'label' => 'Nicht verwenden (zeigt die klassische Einzelansicht)'
- 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 Frontend has an overall complexity of 68 which is very high. The configured complexity threshold is 50. Open
class Frontend
{
/**
* @var Formatter
*/
- Exclude checks
The class Data has an overall complexity of 63 which is very high. The configured complexity threshold is 50. Open
class Data
{
/**
* @var Options
*/
- Exclude checks
The class Advanced has 11 public methods. Consider refactoring Advanced to keep number of public methods under 10. Open
class Advanced extends SubPage
{
/**
* @var array[]
*/
- 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 IncidentReport has an overall complexity of 55 which is very high. The configured complexity threshold is 50. Open
class IncidentReport
{
/**
* Wenn es sich um einen bestehenden Beitrag handelt, ist hier das WordPress-Beitragsobjekt gespeichert.
*
- Exclude checks
The class Formatter has an overall complexity of 102 which is very high. The configured complexity threshold is 50. Open
class Formatter
{
private $tagsNotNeedingPost = array('%feedUrl%', '%yearArchive%');
/**
- Exclude checks
The class Update has an overall complexity of 112 which is very high. The configured complexity threshold is 50. Open
class Update
{
/**
* Fürt ein Update der Datenbank duch
*
- Exclude checks
The class Helper has an overall complexity of 64 which is very high. The configured complexity threshold is 50. Open
class Helper
{
/**
* @var Utilities
*/
- Exclude checks