Method getDetailViewRelatedLinks
has 103 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDetailViewRelatedLinks()
{
$recordModel = $this->getRecord();
$moduleName = $recordModel->getModuleName();
$parentModuleModel = $this->getModule();
Function getDetailViewRelatedLinks
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function getDetailViewRelatedLinks()
{
$recordModel = $this->getRecord();
$moduleName = $recordModel->getModuleName();
$parentModuleModel = $this->getModule();
- 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
Consider simplifying this complex logical expression. Open
if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {
$relatedLinks[] = [
'linktype' => 'DETAILVIEWTAB',
'linklabel' => 'LBL_RECORD_SUMMARY_PRODUCTS_SERVICES',
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',
The method getDetailViewRelatedLinks() has 107 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function getDetailViewRelatedLinks()
{
$recordModel = $this->getRecord();
$moduleName = $recordModel->getModuleName();
$parentModuleModel = $this->getModule();
- Exclude checks
The method getDetailViewRelatedLinks() has an NPath complexity of 38880. The configured NPath complexity threshold is 200. Open
public function getDetailViewRelatedLinks()
{
$recordModel = $this->getRecord();
$moduleName = $recordModel->getModuleName();
$parentModuleModel = $this->getModule();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method getDetailViewRelatedLinks() has a Cyclomatic Complexity of 27. The configured cyclomatic complexity threshold is 10. Open
public function getDetailViewRelatedLinks()
{
$recordModel = $this->getRecord();
$moduleName = $recordModel->getModuleName();
$parentModuleModel = $this->getModule();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed. Open
public function getDetailViewRelatedLinks()
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Avoid using static access to class 'App\Config' in method 'getDetailViewRelatedLinks'. Open
'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Vtiger_Relation_Model' in method 'getDetailViewRelatedLinks'. Open
$relations = \Vtiger_Relation_Model::getAllRelations($parentModuleModel, false, true, true, 'modulename');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Config' in method 'getDetailViewRelatedLinks'. Open
'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\ModuleHierarchy' in method 'getDetailViewRelatedLinks'. Open
&& false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName())
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'getDetailViewRelatedLinks'. Open
&& \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Config' in method 'getDetailViewRelatedLinks'. Open
if (App\Config::module($moduleName, 'SHOW_SUMMARY_PRODUCTS_SERVICES')) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getDetailViewRelatedLinks'. Open
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getDetailViewRelatedLinks'. Open
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '126', column '91'). Open
public function getDetailViewRelatedLinks()
{
$recordModel = $this->getRecord();
$moduleName = $recordModel->getModuleName();
$parentModuleModel = $this->getModule();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'Vtiger_Module_Model' in method 'getDetailViewRelatedLinks'. Open
$modCommentsModel = Vtiger_Module_Model::getInstance('ModComments');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Config' in method 'getDetailViewRelatedLinks'. Open
'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Users_Privileges_Model' in method 'getDetailViewRelatedLinks'. Open
$userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Link_Model' in method 'getDetailViewLinks'. Open
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "DETAILVIEWTAB" 8 times. Open
'linktype' => 'DETAILVIEWTAB',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linkurl" 10 times. Open
'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linkicon" 10 times. Open
'linkicon' => 'yfi yfi-change-of-owner',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linklabel" 10 times. Open
'linklabel' => 'LBL_TRANSFER_OWNERSHIP',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linktype" 10 times. Open
'linktype' => 'DETAIL_VIEW_BASIC',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "linkKey" 4 times. Open
'linkKey' => 'LBL_RECORD_PROCESS_WIZARD',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "related" 6 times. Open
'related' => 'Summary',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "countRelated" 3 times. Open
'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "ModTracker" 3 times. Open
if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "LBL_RECORD_SUMMARY" 3 times. Open
'linklabel' => 'LBL_RECORD_SUMMARY',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to undeclared method \Accounts_DetailView_Model::getModule
Open
'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
- Exclude checks
Call to undeclared method \Accounts_DetailView_Model::getModule
Open
if ($this->getRecord()->isEditable() && $this->getModule()->isPermitted('DetailTransferOwnership')) {
- Exclude checks
Call to undeclared method \Accounts_DetailView_Model::getWidgets
Open
$this->getWidgets();
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
- Exclude checks
Class extends undeclared class \Vtiger_DetailView_Model
Open
class Accounts_DetailView_Model extends Vtiger_DetailView_Model
- Exclude checks
Reference to undeclared class \Vtiger_DetailView_Model
Open
$linkModelList = parent::getDetailViewLinks($linkParams);
- Exclude checks
Call to undeclared method \Accounts_DetailView_Model::getRecord
Open
if ($this->getRecord()->isEditable() && $this->getModule()->isPermitted('DetailTransferOwnership')) {
- Exclude checks
Call to undeclared method \Accounts_DetailView_Model::getRecord
Open
$recordModel = $this->getRecord();
- Exclude checks
Argument 1 (mixed)
is 'OpenStreetMap'
but \Users_Privileges_Model::hasModulePermission()
takes int
defined at /code/modules/Users/models/Privileges.php:101
Open
if ($userPrivilegesModel->hasModulePermission('OpenStreetMap')) {
- Exclude checks
Call to undeclared method \Accounts_DetailView_Model::getModule
Open
$parentModuleModel = $this->getModule();
- Exclude checks
Call to method getCurrentUserRealId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
- Exclude checks
Reference to undeclared property \Accounts_DetailView_Model->widgetsList
Open
if ($parentModuleModel->isSummaryViewSupported() && $this->widgetsList) {
- Exclude checks
Reference to undeclared property \Accounts_DetailView_Model->record
Open
'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
- Exclude checks
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {
$relatedLinks[] = [
'linktype' => 'DETAILVIEWTAB',
'linklabel' => 'LBL_RECORD_SUMMARY_PRODUCTS_SERVICES',
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',
- 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 120.
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
foreach ($parentModuleModel->getRelations() as $relation) {
if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) {
$relatedLinks[] = [
'linktype' => 'DETAILVIEWRELATED',
'linklabel' => $relation->get('label'),
- 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 110.
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
if (
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
&& \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie
&& false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName())
) {
- 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 98.
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
if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) {
$relatedLinks[] = [
'linktype' => 'DETAILVIEWTAB',
'linklabel' => 'LBL_UPDATES',
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRecentActivities&page=1',
- 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 90.
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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Accounts_DetailView_Model extends Vtiger_DetailView_Model
- Exclude checks
The class Accounts_DetailView_Model is not named in CamelCase. Open
class Accounts_DetailView_Model extends Vtiger_DetailView_Model
{
/** {@inheritdoc} */
public function getDetailViewLinks(array $linkParams): array
{
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
$parentModuleModel = $this->getModule();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=full',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related' => 'ProductsAndServices',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& \App\Module::isModuleActive('Chat') && !\App\RequestUtil::getBrowserInfo()->ie
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 203 characters Open
'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related' => 'Summary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//link which shows the summary information(generally detail of record)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_TRANSFER_OWNERSHIP',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => 'javascript:Vtiger_Detail_Js.triggerTransferOwnership("index.php?module=' . $this->getModule()->getName() . '&view=TransferOwnership&record=' . $this->record->getId() . '")',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAIL_VIEW_BASIC',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDetailViewRelatedLinks()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (class_exists($parentModuleModel->getName() . '_ProcessWizard_Model') && $recordModel->isEditable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=processWizard',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related' => 'Details',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_RECORD_SUMMARY',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (App\Config::module($moduleName, 'SHOW_SUMMARY_PRODUCTS_SERVICES')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relations = \Vtiger_Relation_Model::getAllRelations($parentModuleModel, false, true, true, 'modulename');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_RECORD_PROCESS_WIZARD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkModelList = parent::getDetailViewLinks($linkParams);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modCommentsModel = Vtiger_Module_Model::getInstance('ModComments');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkclass' => 'btn-outline-dark btn-sm',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $linkModelList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkKey' => 'LBL_RECORD_PROCESS_WIZARD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($parentModuleModel->isCommentEnabled() && $modCommentsModel->isPermitted('DetailView')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related' => 'ModTracker',
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
'countRelated' => App\Config::module('ModTracker', 'UNREVIEWED_COUNT') && $parentModuleModel->isPermitted('ReviewingUpdates'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showOpenStreetMap',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'fas fa-comments',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'relatedModuleName' => $relation->get('relatedModuleName'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getRecord()->isEditable() && $this->getModule()->isPermitted('DetailTransferOwnership')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkKey' => 'LBL_RECORD_SUMMARY',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showDetailViewByMode&requestMode=summary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related' => 'Summary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& false !== \App\ModuleHierarchy::getModuleLevel($parentModuleModel->getName())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'relationId' => $relation->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $recordModel->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Line exceeds 120 characters; contains 241 characters Open
if (isset($relations['Products']) || isset($relations['Services']) || isset($relations['OSSOutsourcedServices']) || isset($relations['Assets']) || isset($relations['OSSSoldServices']) || isset($relations['OutsourcedProducts'])) {
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRelatedProductsServices&requestMode=summary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'related' => $modCommentsModel->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($parentModuleModel->isTrackingEnabled() && $parentModuleModel->isPermitted('ModTracker')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showRecentActivities&page=1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'badgeClass' => 'bgDanger',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\User::getCurrentUserId() === \App\User::getCurrentUserRealId()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($parentModuleModel->getRelations() as $relation) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_RECORD_DETAILS',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkKey' => 'LBL_RECORD_DETAILS',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showChat',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$massActionLink = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'yfi yfi-change-of-owner',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_RECORD_SUMMARY_PRODUCTS_SERVICES',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_CHAT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWRELATED',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = $this->getRecord();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relatedLinks[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'ModComments',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $recordModel->getDetailViewUrl() . '&mode=showAllComments',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_UPDATES',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($userPrivilegesModel->hasModulePermission('OpenStreetMap')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => $relation->get('label'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $relation->getListUrl($recordModel),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $relatedLinks;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDetailViewLinks(array $linkParams): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$linkModelList['DETAIL_VIEW_BASIC'][] = Vtiger_Link_Model::getInstanceFromValues($massActionLink);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($parentModuleModel->isSummaryViewSupported() && $this->widgetsList) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_MAP',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->getWidgets();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkKey' => 'LBL_RECORD_SUMMARY',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'DETAILVIEWTAB',
- Exclude checks
Line exceeds 120 characters; contains 185 characters Open
if ($relation->isRelatedViewType('RelatedTab') && (!$relation->isDirectRelation() || !($relationField = $relation->getRelationField()) || $relationField->isActiveField())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'countRelated' => App\Config::relation('SHOW_RECORDS_COUNT'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
- Exclude checks
Class name "Accounts_DetailView_Model" is not in camel caps format Open
class Accounts_DetailView_Model extends Vtiger_DetailView_Model
- Exclude checks
Expected 0 spaces after opening bracket; newline found Open
if (
- Exclude checks