andersondanilo/CnabPHP

View on GitHub

Showing 184 of 184 total issues

Function configure has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function configure(array $params)
    {
        $campos = array(
            'data_geracao', 'data_gravacao', 'nome_fantasia', 'razao_social', 'cnpj', 'logradouro', 'numero', 'bairro',
            'cidade', 'uf', 'cep', 'agencia', 'conta'
Severity: Minor
Found in src/Cnab/Remessa/Cnab400/Arquivo.php - About 2 hrs 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

Method identifyFile has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function identifyFile($filename)
    {
        if (!file_exists($filename)) {
            throw new \Exception('file dont exists: '.$filename);
        }
Severity: Major
Found in src/Cnab/Format/Identifier.php - About 2 hrs to fix

    Function decode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    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/Cnab/Format/Picture.php - About 2 hrs 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 validateCollision has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function validateCollision($fields)
        {
            foreach ($fields as $name => $field) {
                $pos_start = $field['pos'][0];
                $pos_end = $field['pos'][1];
    Severity: Minor
    Found in src/Cnab/Format/YamlLoad.php - About 2 hrs 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

    Method __construct has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct($codigo_banco, $filename, $layoutVersao = null)
        {
            $this->filename = $filename;
            $this->layoutVersao = $layoutVersao;
    
    
    Severity: Major
    Found in src/Cnab/Retorno/Cnab240/Arquivo.php - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  $tabela = array(
                      'AA' => 'CAIXA ELETRÔNICO BANCO ITAÚ',
                      'AC' => 'PAGAMENTO EM CARTÓRIO AUTOMATIZADO',
                      'AO' => 'ACERTO ONLINE',
                      'BC' => 'BANCOS CORRESPONDENTES',
      Severity: Major
      Found in src/Cnab/Retorno/Cnab400/Detalhe.php and 1 other location - About 2 hrs to fix
      tests/Cnab/Remessa/Cnab240/CaixaTest.php on lines 109..134

      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 122.

      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

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  'headerLote' => array(
                      '1:3' => '104', // codigo_banco 
                      '4:7' => '0001', // lote_servico 
                      '8:8' => '1', // tipo_registro 
                      '9:9' => 'R', // tipo_operacao 
      Severity: Major
      Found in tests/Cnab/Remessa/Cnab240/CaixaTest.php and 1 other location - About 2 hrs to fix
      src/Cnab/Retorno/Cnab400/Detalhe.php on lines 564..589

      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 122.

      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

      Further Reading

      File BancoDoBrasilTest.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Cnab\Tests\Remessa\Cnab240;
      
      class BancoDoBrasilTest extends \PHPUnit_Framework_TestCase
      Severity: Minor
      Found in tests/Cnab/Remessa/Cnab240/BancoDoBrasilTest.php - About 2 hrs to fix

        Function formatarNossoNumero has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function formatarNossoNumero($nossoNumero)
            {
                if(!$nossoNumero)
                    return $nossoNumero;
        
        
        Severity: Minor
        Found in src/Cnab/Remessa/Cnab240/Arquivo.php - About 1 hr 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

        Method encode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        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/Cnab/Format/Picture.php - About 1 hr to fix

          Method getAlegacaoPagador has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getAlegacaoPagador()
              {
                  // @TODO: implementar funçao getAlegacaoPagador nos outros bancos
                  if ($this->_codigo_banco == 341) {
                      if ($this->getCodigo() == 25) {
          Severity: Minor
          Found in src/Cnab/Retorno/Cnab400/Detalhe.php - About 1 hr to fix

            Method getText has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getText()
                {
                    $numero_sequencial_lote = 1;
                    $qtde_registro_lote = 2; // header e trailer = 2
                    $qtde_titulo_cobranca_simples = 0;
            Severity: Minor
            Found in src/Cnab/Remessa/Cnab240/Arquivo.php - About 1 hr to fix

              Method testArquivoItauCnab400PodeSerLido has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function testArquivoItauCnab400PodeSerLido()
                  {
                      $factory = new \Cnab\Factory();
                      $arquivo = $factory->createRetorno('tests/fixtures/cnab400/retorno-cnab400-itau.ret');
                      $this->assertNotNull($arquivo);
              Severity: Minor
              Found in tests/Cnab/Retorno/Cnab400/ArquivoTest.php - About 1 hr to fix

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        foreach ($asserts as $tipo => $campos) {
                            $vname = "{$tipo}Text";
                            foreach ($campos as $pos => $value) {
                                $aux = explode(':', $pos);
                                $start = $aux[0] - 1;
                Severity: Major
                Found in tests/Cnab/Remessa/Cnab240/CaixaTest.php and 1 other location - About 1 hr to fix
                tests/Cnab/Remessa/Cnab240/BancoDoBrasilTest.php on lines 254..262

                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 116.

                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

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                        foreach ($asserts as $tipo => $campos) {
                            $vname = "{$tipo}Text";
                            foreach ($campos as $pos => $value) {
                                $aux = explode(':', $pos);
                                $start = $aux[0] - 1;
                Severity: Major
                Found in tests/Cnab/Remessa/Cnab240/BancoDoBrasilTest.php and 1 other location - About 1 hr to fix
                tests/Cnab/Remessa/Cnab240/CaixaTest.php on lines 248..256

                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 116.

                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

                Further Reading

                Function getEncoded has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getEncoded()
                    {
                        if ($this->validate()) {
                            $max_pos_end = 0;
                            $dados = '';
                Severity: Minor
                Found in src/Cnab/Format/Linha.php - About 1 hr 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        $array = array(
                            'generic' => array(
                                'codigo_banco' => array(
                                    'pos' => array(1, 3),
                                    'picture' => '',
                Severity: Major
                Found in tests/Cnab/Format/YamlLoadTest.php and 1 other location - About 1 hr to fix
                tests/Cnab/Format/YamlLoadTest.php on lines 60..81

                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 112.

                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

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        $array = array(
                            'generic' => array(
                                'codigo_banco' => array(
                                    'pos' => array(1, 3),
                                    'picture' => '',
                Severity: Major
                Found in tests/Cnab/Format/YamlLoadTest.php and 1 other location - About 1 hr to fix
                tests/Cnab/Format/YamlLoadTest.php on lines 89..110

                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 112.

                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

                Further Reading

                Method testArquivoCaixaSigcbPodeSerLido has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function testArquivoCaixaSigcbPodeSerLido()
                    {
                        $factory = new \Cnab\Factory();
                        $arquivo = $factory->createRetorno('tests/fixtures/cnab240/retorno_cnab240_caixa.ret');
                        $this->assertNotNull($arquivo);
                Severity: Minor
                Found in tests/Cnab/Retorno/Cnab240/ArquivoTest.php - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                              'segmentoQ' => array(
                                  '1:3' => '104', // codigo_banco 
                                  '4:7' => '0001', // lote_servico 
                                  '8:8' => '3', // tipo_registro 
                                  '9:13' => '00002', // numero_sequencial_lote 
                  Severity: Major
                  Found in tests/Cnab/Remessa/Cnab240/CaixaTest.php and 1 other location - About 1 hr to fix
                  tests/Cnab/Remessa/Cnab240/BancoDoBrasilTest.php on lines 192..214

                  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 111.

                  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

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language