andersondanilo/CnabPHP

View on GitHub

Showing 184 of 184 total issues

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

            'segmentoQ' => array(
                '1:3' => '001', // 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/BancoDoBrasilTest.php and 1 other location - About 1 hr to fix
tests/Cnab/Remessa/Cnab240/CaixaTest.php on lines 181..203

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

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

    public function __construct($codigo_banco, $filename, $layoutVersao = null)
    {
        $this->filename = $filename;
        $this->layoutVersao = $layoutVersao;

Severity: Minor
Found in src/Cnab/Retorno/Cnab400/Arquivo.php - About 1 hr to fix

    Method getCodigoNome has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getCodigoNome()
        {
            $codigo = (int) $this->getCodigo();
    
            $table = array(
    Severity: Minor
    Found in src/Cnab/Retorno/Cnab240/Detalhe.php - About 1 hr to fix

      Method getDescricaoLiquidacao has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getDescricaoLiquidacao()
          {
              // @TODO: Usar YAML (cnab_yaml) para criar tabela de descrição
              $codigoLiquidacao = $this->getCodigoLiquidacao();
              $tabela = array();
      Severity: Minor
      Found in src/Cnab/Retorno/Cnab400/Detalhe.php - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                    if (($pos_start >= $current_pos_start && $pos_start <= $current_pos_end) ||
                         ($pos_end <= $current_pos_end && $pos_end >= $current_pos_start) ||
                         ($current_pos_start >= $pos_start && $current_pos_start <= $pos_end) ||
                         ($current_pos_end <= $pos_end && $current_pos_end >= $pos_start)) {
                        unset($this->fields[$key]);
        Severity: Critical
        Found in src/Cnab/Format/Linha.php - About 1 hr to fix

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

                  foreach ($campos as $campo) {
                      if (array_key_exists($campo, $params)) {
                          if (strpos($campo, 'data_') === 0 && !($params[$campo] instanceof \DateTime)) {
                              throw new \Exception("config '$campo' need to be instance of DateTime");
                          }
          Severity: Major
          Found in src/Cnab/Remessa/Cnab240/Arquivo.php and 1 other location - About 1 hr to fix
          src/Cnab/Remessa/Cnab400/Arquivo.php on lines 53..62

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

          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 ($campos as $campo) {
                      if (array_key_exists($campo, $params)) {
                          if (strpos($campo, 'data_') === 0 && !($params[$campo] instanceof \DateTime)) {
                              throw new \Exception("config '$campo' need to be instance of DateTime");
                          }
          Severity: Major
          Found in src/Cnab/Remessa/Cnab400/Arquivo.php and 1 other location - About 1 hr to fix
          src/Cnab/Remessa/Cnab240/Arquivo.php on lines 58..67

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

          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 formatarNossoNumero has 33 lines of code (exceeds 25 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

            Function __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function __construct($codigo_banco, $filename, $layoutVersao = null)
                {
                    $this->filename = $filename;
                    $this->layoutVersao = $layoutVersao;
            
            
            Severity: Minor
            Found in src/Cnab/Retorno/Cnab400/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

            Function addField has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function addField($nome, $pos_start, $pos_end, $format, $default, $options)
                {
                    foreach ($this->fields as $key => $field) {
                        $current_pos_start = $field->pos_start;
                        $current_pos_end = $field->pos_end;
            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

            Method getBanco has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getBanco($codigo)
                {
                    if ($codigo == self::BANCO_DO_BRASIL) {
                        return array(
                            'codigo_do_banco' => self::BANCO_DO_BRASIL,
            Severity: Minor
            Found in src/Cnab/Banco.php - About 1 hr to fix

              Function getText has a Cognitive Complexity of 10 (exceeds 5 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

              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 getAlegacaoPagador has a Cognitive Complexity of 10 (exceeds 5 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

              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 addField has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function addField($nome, $pos_start, $pos_end, $format, $default, $options)
              Severity: Minor
              Found in src/Cnab/Format/Linha.php - About 45 mins to fix

                Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function __construct(Linha $linha, $nome, $format, $pos_start, $pos_end, $options)
                Severity: Minor
                Found in src/Cnab/Format/Field.php - About 45 mins to fix

                  Function createRetorno has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function createRetorno($filename)
                      {
                          $identifier = new Format\Identifier();
                  
                          if (empty($filename)) {
                  Severity: Minor
                  Found in src/Cnab/Factory.php - About 45 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 mod11 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function mod11($num, $base = 9, $r = 0)
                      {
                          $soma = 0;
                          $fator = 2;
                          /* Separacao dos numeros */
                  Severity: Minor
                  Found in src/Cnab/Remessa/Cnab240/Arquivo.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 insertSegmento has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function insertSegmento($linha)
                      {
                          $codigo_segmento = strtoupper(substr($linha, 13, 1));
                          $segmento = null;
                          if ('T' == $codigo_segmento) {
                  Severity: Minor
                  Found in src/Cnab/Retorno/Cnab240/Lote.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 loadArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function loadArray(Linha $cnabLinha, $array)
                      {
                          $this->validateArray($array);
                  
                          $keys = array('generic');
                  Severity: Minor
                  Found in src/Cnab/Format/YamlLoad.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

                  Avoid too many return statements within this method.
                  Open

                                  return 'Abatimento Concedido';
                  Severity: Major
                  Found in src/Cnab/Retorno/Cnab400/Detalhe.php - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language