andersondanilo/CnabPHP

View on GitHub

Showing 172 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

      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

                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

                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

                  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

                          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

                            Severity
                            Category
                            Status
                            Source
                            Language