Showing 452 of 452 total issues
File Data.php
has 576 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Automatorm\Orm;
use Automatorm\Exception;
use Automatorm\Database\SqlString;
Function generate
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
public function generate()
{
$data = $this->connection->data;
$database = $this->connection->schemaName;
- 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 generate
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public function generate()
{
$connection = $this->connection;
$model = [];
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($columnparts[5] ?: $columnparts[6]) {
$this->database = $this->escape($columnparts[1] ?: $columnparts[2]);
$this->schema = $this->escape($columnparts[3] ?: $columnparts[4]);
$this->column = $this->escape($columnparts[5] ?: $columnparts[6]);
} elseif ($columnparts[3] ?: $columnparts[4]) {
- 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 227.
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
if ($columnparts[5] ?: $columnparts[6]) {
$this->database = $this->escape($columnparts[1] ?: $columnparts[2]);
$this->schema = $this->escape($columnparts[3] ?: $columnparts[4]);
$this->table = $this->escape($columnparts[5] ?: $columnparts[6]);
} elseif ($columnparts[3] ?: $columnparts[4]) {
- 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 227.
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
Function filter
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public function filter($filter, $invertAffix = false)
{
$copy = $this->container;
if (is_array($filter)) {
- 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 generateData
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public function generateData($connection)
{
list($schema, $database) = $connection->getSchemaGenerator()->generate();
$currentTable = null;
- 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 format
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
public static function format($key, $value, $seen = [], $collectionCount = 0, $exceptionThrown = false)
{
switch (true) {
case $value instanceof Model:
$namespace = explode('\\', get_class($value));
- 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
Data
has 39 functions (exceeds 20 allowed). Consider refactoring. Open
class Data
{
protected $data = []; // Data from columns on this table
protected $external = []; // Links to foreign key objects
Method generate
has 129 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate()
{
$connection = $this->connection;
$model = [];
Method format
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function format($key, $value, $seen = [], $collectionCount = 0, $exceptionThrown = false)
{
switch (true) {
case $value instanceof Model:
$namespace = explode('\\', get_class($value));
QueryBuilder
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class QueryBuilder
{
const ENGINES = ['mysql', 'postgres', 'mssql'];
public static $engine = "mysql";
public static $requireWhereClause = true;
Function generate
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public static function generate($path, Schema $schema)
{
$namespace = $schema->namespace;
foreach ($schema->model as $model) {
- 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 commit
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function commit($mode, $table, $id, $data, $externalData, $schema) : int
{
if ($mode == 'delete') {
$this->data->delete($table, $id);
return $id;
- 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
Collection
has 32 functions (exceeds 20 allowed). Consider refactoring. Open
class Collection implements \ArrayAccess, \Iterator, \Countable, \JsonSerializable
{
// From Hodgepodge
protected $container = [];
Method generate
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate()
{
$data = $this->connection->data;
$database = $this->connection->schemaName;
File QueryBuilder.php
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Query Builder - build SQL queries programatically
*
* @package Automatorm\Database
Function __construct
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function __construct($column)
{
// Cowardly refuse to process SqlStrings
if ($column instanceof SqlString) {
$this->column = (string) $column;
- 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 dumpModel
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public static function dumpModel(Model $model)
{
$data_access = function ($var) {
return $this->$var;
};
- 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 dumpModel
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function dumpModel(Model $model)
{
$data_access = function ($var) {
return $this->$var;
};