File Tracking.php
has 804 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Functions used for database and table tracking
*/
Tracking
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class Tracking
{
public function __construct(
private SqlQueryForm $sqlQueryForm,
public Template $template,
Method getTrackedData
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTrackedData(string $dbname, string $tablename, string $version): TrackedData
{
$trackingFeature = $this->relation->getRelationParameters()->trackingFeature;
Assert::notNull($trackingFeature);
Method getHtmlForTrackingReport
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHtmlForTrackingReport(
TrackedData $trackedData,
array $urlParams,
string $logType,
array $filterUsers,
Function getTrackingSet
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getTrackingSet(): string
{
$trackingSet = '';
// a key is absent from the request if it has been removed from
- 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 getTrackedData
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getTrackedData(string $dbname, string $tablename, string $version): TrackedData
{
$trackingFeature = $this->relation->getRelationParameters()->trackingFeature;
Assert::notNull($trackingFeature);
- 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 getTrackingSet
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTrackingSet(): string
{
$trackingSet = '';
// a key is absent from the request if it has been removed from
Method getHtmlForTrackingReportExportForm1
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
TrackedData $trackedData,
array $urlParams,
string $logType,
array $filterUsers,
string $str1,
Method getHtmlForTrackingReportExportForm1
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHtmlForTrackingReportExportForm1(
TrackedData $trackedData,
array $urlParams,
string $logType,
array $filterUsers,
Method getHtmlForTrackingReportExportForm2
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
array $urlParams,
string $str1,
string $str2,
string $str3,
string $str4,
Method getHtmlForTrackingReportExportForm2
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHtmlForTrackingReportExportForm2(
array $urlParams,
string $str1,
string $str2,
string $str3,
Method getHtmlForSchemaSnapshot
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHtmlForSchemaSnapshot(string $db, string $table, string $version, array $params): string
{
$html = '<h3>' . __('Structure snapshot')
. ' [<a href="' . Url::getFromRoute('/table/tracking', $params) . '">' . __('Close')
. '</a>]</h3>';
Method getHtmlForDbTrackingTables
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHtmlForDbTrackingTables(
string $db,
array $urlParams,
string $textDir,
): string {
Method getHtmlForDataStatements
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
array $logData,
array $filterUsers,
array $urlParams,
string $dropImageOrText,
LogTypeEnum $logType,
Method getHtmlForDataStatements
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getHtmlForDataStatements(
array $logData,
array $filterUsers,
array $urlParams,
string $dropImageOrText,
Method getHtmlForDataManipulationStatements
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
TrackedData $trackedData,
array $filterUsers,
array $urlParams,
int $ddlogCount,
string $dropImageOrText,
Method getHtmlForTrackingReport
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
TrackedData $trackedData,
array $urlParams,
string $logType,
array $filterUsers,
string $version,
Method getHtmlForDataDefinitionStatements
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
TrackedData $trackedData,
array $filterUsers,
array $urlParams,
string $dropImageOrText,
string $version,
Method deleteFromTrackingReportLog
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $db,
string $table,
string $version,
array $logData,
LogTypeEnum $logType,
Method getEntries
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
TrackedData $trackedData,
array $filterUsers,
string $logType,
DateTimeImmutable $dateFrom,
DateTimeImmutable $dateTo,
Method changeTrackingData
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $dbName,
string $tableName,
string $version,
LogTypeEnum $logType,
array $newData,
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private SqlQueryForm $sqlQueryForm,
public Template $template,
protected Relation $relation,
private DatabaseInterface $dbi,
private TrackingChecker $trackingChecker,
Function getHtmlForTrackingReportExportForm1
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getHtmlForTrackingReportExportForm1(
TrackedData $trackedData,
array $urlParams,
string $logType,
array $filterUsers,
- 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
foreach ($logSchemaEntries as $logEntry) {
if (trim($logEntry) == '') {
continue;
}
- 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 150.
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
foreach ($logDataEntries as $logEntry) {
if (trim($logEntry) == '') {
continue;
}
- 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 150.
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