abrain/einsatzverwaltung

View on GitHub

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();
Severity: Minor
Found in src/Admin/ReportListTable.php - About 25 mins to fix

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();

Severity: Minor
Found in src/CustomFieldsRepository.php - About 25 mins to fix

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);
Severity: Minor
Found in src/Import/Sources/Csv.php - About 25 mins to fix

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>';

Severity: Minor
Found in src/Admin/TasksPage.php - About 25 mins to fix

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',
Severity: Minor
Found in src/Export/Formats/AbstractFormat.php - About 25 mins to fix

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);

Severity: Minor
Found in src/Types/Vehicle.php - About 25 mins to fix

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) {
Severity: Minor
Found in src/Types/Vehicle.php - About 25 mins to fix

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'));
Severity: Minor
Found in src/Utilities.php - About 25 mins to fix

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
Severity: Minor
Found in src/Data.php - About 25 mins to fix

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);

Severity: Minor
Found in src/Types/Unit.php - About 25 mins to fix

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();
Severity: Minor
Found in src/Import/Tool.php by phpmd

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;
    }
Severity: Minor
Found in src/Model/ReportAnnotation.php by phpmd

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(),
Severity: Minor
Found in src/DataAccess/ReportInserter.php by phpmd

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']);
Severity: Minor
Found in src/Api/Reports.php by phpmd

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;
        }
Severity: Minor
Found in src/Util/Formatter.php by phpmd

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();
Severity: Minor
Found in src/Import/Sources/Csv.php by phpmd

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()));
Severity: Minor
Found in src/Widgets/RecentIncidents.php by phpmd

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');
        }
Severity: Minor
Found in src/Update.php by phpmd

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');
Severity: Minor
Found in src/Update.php by phpmd

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) {
Severity: Minor
Found in src/Export/Formats/AbstractFormat.php by phpmd

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Severity
Category
Status
Source
Language