The method setRelationTables has a boolean flag argument $secmodule, which is a certain sign of a Single Responsibility Principle violation. Open
public function setRelationTables($secmodule = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Define a constant instead of duplicating this literal "vtiger_crmentity" 3 times. Open
public $tab_name = ['vtiger_crmentity', 'vtiger_faq', 'vtiger_faqcf'];
- 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 "subject" 4 times. Open
'FL_SUBJECT' => 'subject',
- 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 "vtiger_faqcf" 3 times. Open
public $tab_name = ['vtiger_crmentity', 'vtiger_faq', 'vtiger_faqcf'];
- 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.
Remove this commented out code. Open
* Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Define a constant instead of duplicating this literal "vtiger_faq" 4 times. Open
public $table_name = 'vtiger_faq';
- 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.
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Faq extends CRMEntity
- Exclude checks
The property $search_fields is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $mandatory_fields is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $default_sort_order is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $entity_table is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $search_fields_name is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $table_name is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $column_fields is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $table_index is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $def_basicsearch_col is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $list_fields_name is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $default_order_by is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $tab_name_index is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $tab_name is not named in camelCase. Open
class Faq extends CRMEntity
{
public $table_name = 'vtiger_faq';
public $table_index = 'id';
//fix for Custom Field for FAQ
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
public $list_fields_name = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $column_fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table_name = 'vtiger_faq';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_SUBJECT' => 'subject',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tab_name = ['vtiger_crmentity', 'vtiger_faq', 'vtiger_faqcf'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Format: Field Label => fieldname
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//fix for Custom Field for FAQ
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $tab_name_index = ['vtiger_crmentity' => 'crmid', 'vtiger_faq' => 'id', 'vtiger_faqcf' => 'faqid'];
- 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
'FL_SUBJECT' => ['faq', 'subject'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_CATEGORY' => ['faq', 'category'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// For Alphabetical search
- 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
'FL_STATUS' => 'faqstatus',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $search_fields_name = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Added these variables which are used as default order by and sortorder in ListView
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $def_basicsearch_col = 'subject';
- 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
// tablename should not have prefix 'vtiger_'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $entity_table = 'vtiger_crmentity';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Format: Field Label => Array(tablename, columnname)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_order_by = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Documents' => ['vtiger_senotesrel' => ['crmid', 'notesid'], 'vtiger_faq' => 'id'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $table_index = 'id';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $customFieldTable = ['vtiger_faqcf', 'faqid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_CATEGORY' => 'category',
- 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
public $relationFields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_INTRODUCTION' => ['faq', 'introduction'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Assigned To' => 'assigned_user_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_INTRODUCTION' => 'introduction',
- 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
* @var string[] List of fields in the RelationListView
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $default_sort_order = 'DESC';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $mandatory_fields = ['subject'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool|string $secmodule secondary module name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $search_fields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Assigned To' => ['crmentity', 'smownerid'],
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $relTables;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $relTables[$secmodule];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === $secmodule) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relTables = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FL_STATUS' => ['faq', 'status'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the relation tables for related modules.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array returns the array with table names and fieldnames storing relations between module and this module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setRelationTables($secmodule = false)
- 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks