eidng8/sttbot

View on GitHub

Showing 223 of 223 total issues

The method expandTemplates has a boolean flag argument $new, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function expandTemplates(bool $new = false): ExpandTemplates
Severity: Minor
Found in src/Wiki/Api/Api.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method get has a boolean flag argument $fetch, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function get(bool $fetch = false)
Severity: Minor
Found in src/Wiki/Api/Query.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Avoid too many return statements within this method.
Open

        return true;
Severity: Major
Found in src/Wiki/Models/ReqAndBonus.php - About 30 mins to fix

Missing class import via use statement (line '180', column '23').
Open

            throw new \RuntimeException(
Severity: Minor
Found in src/Wiki/Api/Parse.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '150', column '23').
Open

            throw new \RuntimeException(
Severity: Minor
Found in src/Wiki/Api/Parse.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method canPass has a boolean flag argument $critical, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function canPass(MissionStep $step, bool $critical = false): bool
Severity: Minor
Found in src/Wiki/Models/CrewMember.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Function mapMissionAttributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function mapMissionAttributes(array $missions): array
    {
        $ret = [];
        foreach ($missions as $mission) {
            if (empty($mission['steps'])) {
Severity: Minor
Found in src/Wiki/Exporter.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 offsetSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function offsetSet($offset, $value)
    {
        switch (strtolower($offset)) {
            case 'crewname':
                list($this->name, $this->page) = $this->parseName($value);
Severity: Minor
Found in src/Wiki/Models/CrewMember.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 fetchCadetCrew has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function fetchCadetCrew(array $names, array $cadet)
    {
        foreach ($cadet as $episode => $missions) {
            $this->parse->page($names[$episode], 2);
            preg_match_all(
Severity: Minor
Found in src/Wiki/Templates/MissionList.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 canUnlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function canUnlock(MissionStep $step): bool
    {
        foreach ($step->locks as $lock) {
            if (empty($lock)) {
                continue;
Severity: Minor
Found in src/Wiki/Models/CrewMember.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 each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function each(callable $func): void
    {
        foreach ($this->list as $type => $episodes) {
            foreach ($episodes as $episode => $missions) {
                foreach ($missions as $index => $mission) {
Severity: Minor
Found in src/Wiki/Templates/MissionList.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 parseMissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseMissions(array $missions, string $episode): array
    {
        $info = [];
        $adv = 'adv:' == strtolower(substr($episode, 0, 4));
        foreach ($missions as $mission) {
Severity: Minor
Found in src/Wiki/Templates/MissionList.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 using static access to class '\Mockery' in method 'testGetNull'.
Open

        $mock = Mockery::mock(
            ExpandTemplates::class . '[cache]',
            [Http::shouldRespond([])],
            ['cache' => null]
        );

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method stepBestCrew uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $member = $this->bestMember(
                $step->getCrew()['pass'],
                $skills,
                $member
Severity: Minor
Found in src/Wiki/Analyst.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\eidng8\Log\Log' in method 'validate'.
Open

                    Log::warn(
                        "Mission [ $this->name ] step ( $idx ) is empty.",
                        [$this]
                    );
Severity: Minor
Found in src/Wiki/Models/Mission.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\eidng8\Log\Log' in method 'validate'.
Open

                    Log::warn(
                        "Mission [ $this->name ] step ( $idx ) is invalid.",
                        [$this]
                    );
Severity: Minor
Found in src/Wiki/Models/Mission.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\eidng8\Wiki\Template' in method 'parseMWHead'.
Open

                $traits = Template::explode($found[1][0]);
Severity: Minor
Found in src/Wiki/Templates/Mission.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method parseStep uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $alt = null;
            }
Severity: Minor
Found in src/Wiki/Templates/Mission.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class 'eidng8\Wiki\Templates\Triple' in method 'parseStepProp'.
Open

                        $adv = Triple::empty($triple->name);
Severity: Minor
Found in src/Wiki/Templates/Mission.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method parse uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    $this->model->normal($triple->normal());
                    $this->model->elite($triple->elite());
                    $this->model->epic($triple->epic());
                }
Severity: Minor
Found in src/Wiki/Templates/MissionCost.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Severity
Category
Status
Source
Language