GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Condition/Track/LocationCondition.php

Summary

Maintainability
A
1 hr
Test Coverage
F
36%

Function getUsedFieldsValues has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getUsedFieldsValues(\Gems_Tracker_RespondentTrack $respTrack, array $fieldData = null)
    {
        $defs      = $respTrack->getTrackEngine()->getFieldsDefinition();
        $fields    = $fieldData ? $fieldData : $respTrack->getFieldData();
        $forCode   = $this->_data['gcon_condition_text4'];
Severity: Minor
Found in classes/Gems/Condition/Track/LocationCondition.php - About 35 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 getTrackDisplay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getTrackDisplay($trackId)
    {
        if ($this->_data['gcon_condition_text4']) {
            $start = sprintf($this->_('A location field with code %s set to: '),
                             $this->_data['gcon_condition_text4']);
Severity: Minor
Found in classes/Gems/Condition/Track/LocationCondition.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

Avoid unused parameters such as '$new'.
Open

    public function getModelFields($context, $new)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$context'.
Open

    public function getModelFields($context, $new)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused local variables such as '$key'.
Open

        foreach ($this->getUsedFieldsValues($respTrack, $fieldData) as $key => $value) {

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid unused parameters such as '$value'.
Open

    public function getNotValidReason($value, $context)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

Avoid unused parameters such as '$context'.
Open

    public function getNotValidReason($value, $context)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

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

There are no issues that match your filters.

Category
Status