hisamu/php-xbase

View on GitHub

Showing 25 of 29 total issues

TableReader has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class TableReader
{
    use TableAwareTrait;

    /** @var int Current record position. */
Severity: Minor
Found in src/TableReader.php - About 4 hrs to fix

    AbstractRecord has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class AbstractRecord implements RecordInterface
    {
        public const FLAG_NOT_DELETED = 0x20;
        public const FLAG_DELETED = 0x2a;
    
    
    Severity: Minor
    Found in src/Record/AbstractRecord.php - About 3 hrs to fix

      Function open has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function open(): void
          {
              switch ($this->table->options['editMode']) {
                  case self::EDIT_MODE_CLONE:
                      $this->clone();
      Severity: Minor
      Found in src/TableEditor.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

      File TableReader.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php declare(strict_types=1);
      
      namespace XBase;
      
      use XBase\Column\ColumnInterface;
      Severity: Minor
      Found in src/TableReader.php - About 2 hrs to fix

        Function pack has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function pack(): self
            {
                $newRecordCount = 0;
                for ($i = 0; $i < $this->getRecordCount(); $i++) {
                    $r = $this->moveTo($i);
        Severity: Minor
        Found in src/TableEditor.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 open has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function open(): void
            {
                switch ($this->table->options['editMode']) {
                    case self::EDIT_MODE_CLONE:
                        $this->clone();
        Severity: Minor
        Found in src/TableEditor.php - About 1 hr to fix

          Method get has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get(int $pointer): ?MemoObject
              {
                  if (!$this->isOpen()) {
                      $this->open();
                  }
          Severity: Minor
          Found in src/Memo/DBase3Memo.php - About 1 hr to fix

            Method createFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function createFile(string $filepath, int $columnsCount): void
            {
                $header = HeaderFactory::create(TableType::DBASE_III_PLUS_MEMO);
            
                $tableCreator = new TableCreator($filepath, $header);
            Severity: Minor
            Found in example/test-columns.php - About 1 hr to fix

              Function get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function get(int $pointer): ?MemoObject
                  {
                      if (!$this->isOpen()) {
                          $this->open();
                      }
              Severity: Minor
              Found in src/Memo/DBase3Memo.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 collectPerformanceInfo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function collectPerformanceInfo(string $filepath, int $iterations = 100, array $columns = [])
              {
                  $timetable = [];
              
                  printf('Reading all data'.PHP_EOL);
              Severity: Minor
              Found in example/test-columns.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 previousRecord has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function previousRecord(): ?RecordInterface
                  {
                      if (!$this->isOpen()) {
                          $this->open();
                      }
              Severity: Minor
              Found in src/TableReader.php - About 1 hr to fix

                Method guessDataType has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function guessDataType(string $string): array
                    {
                        if (strlen($string) > 4) {
                            $bytes = unpack('n*', substr($string, 0, 4));
                            switch ($bytes[1]) {
                Severity: Minor
                Found in src/Memo/AbstractMemo.php - About 1 hr to fix

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

                      public function __construct(string $data, ?int $type = null, ?int $pointer = null, ?int $length = null, ?array $info = [])
                  Severity: Minor
                  Found in src/Memo/MemoObject.php - About 35 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $this->setVarchar($column, $value);
                    Severity: Major
                    Found in src/Record/VisualFoxproRecord.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return new DBaseDataConverter($table, $encoder);
                      Severity: Major
                      Found in src/Record/RecordFactory.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $this->setNum($column, $value);
                        Severity: Major
                        Found in src/Record/AbstractRecord.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $this->setMemo($column, $value);
                          Severity: Major
                          Found in src/Record/AbstractRecord.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return $this->setFloat($column, $value);
                            Severity: Major
                            Found in src/Record/VisualFoxproRecord.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return parent::set($columnName, $value);
                              Severity: Major
                              Found in src/Record/VisualFoxproRecord.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return $this->setGeneral($column, $value);
                                Severity: Major
                                Found in src/Record/VisualFoxproRecord.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language