glauberportella/cnab-layouts-parser

View on GitHub

Showing 93 of 93 total issues

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

        $titulos = array(); // titulos tem titulo
Severity: Minor
Found in src/CnabParser/Input/RetornoFile.php by phpmd

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

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

        } else {
            $msg = "%s$format' is not a valid format";

            if (!empty(@$options['field_desc'])) {
                $msg = sprintf($msg, "{$options['field_desc']}: ");
Severity: Minor
Found in src/CnabParser/Format/Picture.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

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

                } else {
                    $msg = "%s$format' is not a valid format";

                    if (!empty(@$options['field_desc'])) {
                        $msg = sprintf($msg, "{$options['field_desc']}: ");
Severity: Minor
Found in src/CnabParser/Format/Picture.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

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

        } else {
            return false;
        }
Severity: Minor
Found in src/CnabParser/Format/Picture.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

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

                    } else {
                        return self::parseNumber($valor_left);
                    }
Severity: Minor
Found in src/CnabParser/Format/Picture.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 '\CnabParser\Format\Picture' in method 'obterValorCampo'.
Open

        return Picture::decode(substr($this->linhaStr, $inicio, $tamanho), $formato, $opcoes);
Severity: Minor
Found in src/CnabParser/Model/Linha.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 parseNumber uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return '0';
        }
Severity: Minor
Found in src/CnabParser/Format/Picture.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

The method testRemessaOk() has 101 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function testRemessaOk()
    {
        $remessaLayout = new Layout(__DIR__.'/../../../config/cef/cnab400/cobranca_sigcb.yml');
        $remessa = new Remessa($remessaLayout);
        $this->assertInstanceOf('CnabParser\Model\Remessa', $remessa);

The method testRemessaPagamentosOk() has 173 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function testRemessaPagamentosOk()
    {
        $remessaLayout = new Layout(__DIR__.'/../../../config/febraban/cnab240/pagamentos.yml');
        $remessa = new Remessa($remessaLayout);
        $this->assertInstanceOf('CnabParser\Model\Remessa', $remessa);

The method encode() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
Open

    public static function encode($value, $format, $options)
    {
        $m = array();
        if (\preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

The method decode() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    public static function decode($value, $format, $options)
    {
        $m = array();
        if (preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

The variable $tamanho_left is not named in camelCase.
Open

    public static function decode($value, $format, $options)
    {
        $m = array();
        if (preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $valor_left is not named in camelCase.
Open

    public static function encode($value, $format, $options)
    {
        $m = array();
        if (\preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tamanho_right is not named in camelCase.
Open

    public static function encode($value, $format, $options)
    {
        $m = array();
        if (\preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $valor_left is not named in camelCase.
Open

    public static function decode($value, $format, $options)
    {
        $m = array();
        if (preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $valor_left is not named in camelCase.
Open

    public static function decode($value, $format, $options)
    {
        $m = array();
        if (preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tamanho_left is not named in camelCase.
Open

    public static function encode($value, $format, $options)
    {
        $m = array();
        if (\preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tamanho_right is not named in camelCase.
Open

    public static function decode($value, $format, $options)
    {
        $m = array();
        if (preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tamanho_right is not named in camelCase.
Open

    public static function encode($value, $format, $options)
    {
        $m = array();
        if (\preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $valor_left is not named in camelCase.
Open

    public static function decode($value, $format, $options)
    {
        $m = array();
        if (preg_match(self::REGEX_VALID_FORMAT, $format, $m)) {
            if ($m['tipo1'] == 'X' && !$m['tipo2']) {
Severity: Minor
Found in src/CnabParser/Format/Picture.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

Severity
Category
Status
Source
Language