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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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));
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
TableReader
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class TableReader
{
use TableAwareTrait;
/** @var int Current record position. */
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;
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();
- Read upRead up
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;
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);
- Read upRead up
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();
Method get
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get(int $pointer): ?MemoObject
{
if (!$this->isOpen()) {
$this->open();
}
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);
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();
}
- Read upRead up
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);
- Read upRead up
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();
}
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]) {
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 = [])
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)) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)) {
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid too many return
statements within this method. Open
return $this->setVarchar($column, $value);
Avoid too many return
statements within this method. Open
return new DBaseDataConverter($table, $encoder);
Avoid too many return
statements within this method. Open
return $this->setNum($column, $value);