hisamu/php-xbase

View on GitHub

Showing 29 of 29 total issues

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

    protected function createColumn(string $memoryChunk): Column
    {
        $header = parent::createColumn($memoryChunk);

        $nameEndIndex = strpos($header->rawName, chr(0x00));
Severity: Major
Found in src/Header/Reader/Column/DBase7ColumnReader.php and 1 other location - About 4 hrs to fix
src/Header/Reader/Column/DBaseColumnReader.php on lines 18..34

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

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

    protected function createColumn(string $memoryChunk): Column
    {
        $header = parent::createColumn($memoryChunk);

        $nameEndIndex = strpos($header->rawName, chr(0x00));
Severity: Major
Found in src/Header/Reader/Column/DBaseColumnReader.php and 1 other location - About 4 hrs to fix
src/Header/Reader/Column/DBase7ColumnReader.php on lines 19..35

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

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

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

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

                        protected function setDouble(Column $column, $value): self
                        {
                            $this->checkType($column, FieldType::DOUBLE);
                    
                            if (is_string($value)) {
                    Severity: Minor
                    Found in src/Record/VisualFoxproRecord.php and 1 other location - About 35 mins to fix
                    src/Record/VisualFoxproRecord.php on lines 109..120

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

                    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

                        protected function setCurrency(Column $column, $value): self
                        {
                            $this->checkType($column, FieldType::CURRENCY);
                    
                            if (is_string($value)) {
                    Severity: Minor
                    Found in src/Record/VisualFoxproRecord.php and 1 other location - About 35 mins to fix
                    src/Record/VisualFoxproRecord.php on lines 96..107

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

                    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

                    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
                          Severity
                          Category
                          Status
                          Source
                          Language