YetiForceCompany/YetiForceCRM

View on GitHub
modules/Documents/Documents.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

The class Documents has 16 fields. Consider redesigning Documents to keep the number of fields under 15.
Open

class Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

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)
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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

Missing class import via use statement (line '78', column '15').
Open

        return (new \App\Db\Query())->select(['tree'])->from('vtiger_trees_templates_data')->where(['tree' => $folderId])->exists();
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '88', column '15').
Open

        return (new \App\Db\Query())->select(['tree', 'name'])->from('vtiger_trees_templates_data')->innerJoin('vtiger_field', 'vtiger_trees_templates_data.templateid = vtiger_field.fieldparams')->where(['vtiger_field.columnname' => 'folderid', 'vtiger_field.tablename' => 'vtiger_notes', 'vtiger_trees_templates_data.name' => 'Default'])->scalar();
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Define a constant instead of duplicating this literal "notes_title" 3 times.
Open

        'Title' => 'notes_title',
Severity: Critical
Found in modules/Documents/Documents.php by sonar-php

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 "notesid" 5 times.
Open

    public $table_index = 'notesid';
Severity: Critical
Found in modules/Documents/Documents.php by sonar-php

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_notes" 4 times.
Open

    public $table_name = 'vtiger_notes';
Severity: Critical
Found in modules/Documents/Documents.php by sonar-php

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_notescf" 3 times.
Open

    public $tab_name = ['vtiger_crmentity', 'vtiger_notes', 'vtiger_notescf'];
Severity: Critical
Found in modules/Documents/Documents.php by sonar-php

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 "filename" 3 times.
Open

        'File Name' => 'filename',
Severity: Critical
Found in modules/Documents/Documents.php by sonar-php

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 \App\Db\Query::select
Open

        return (new \App\Db\Query())->select(['tree', 'name'])->from('vtiger_trees_templates_data')->innerJoin('vtiger_field', 'vtiger_trees_templates_data.templateid = vtiger_field.fieldparams')->where(['vtiger_field.columnname' => 'folderid', 'vtiger_field.tablename' => 'vtiger_notes', 'vtiger_trees_templates_data.name' => 'Default'])->scalar();
Severity: Critical
Found in modules/Documents/Documents.php by phan

Call to undeclared method \App\Db\Query::select
Open

        return (new \App\Db\Query())->select(['tree'])->from('vtiger_trees_templates_data')->where(['tree' => $folderId])->exists();
Severity: Critical
Found in modules/Documents/Documents.php by phan

Avoid excessively long variable names like $default_note_name_dom. Keep variable name length under 20.
Open

    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Avoid excessively long variable names like $additional_column_fields. Keep variable name length under 20.
Open

    public $additional_column_fields = ['', '', '', ''];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Documents extends CRMEntity

The property $search_fields_name is not named in camelCase.
Open

class Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 $old_filename is not named in camelCase.
Open

class Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 $additional_column_fields is not named in camelCase.
Open

class Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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_note_name_dom is not named in camelCase.
Open

class Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 is not named in camelCase.
Open

class Documents extends CRMEntity
{
    public $table_name = 'vtiger_notes';
    public $table_index = 'notesid';
    public $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];
Severity: Minor
Found in modules/Documents/Documents.php by phpmd

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 $default_note_name_dom = ['Meeting vtiger_notes', 'Reminder'];

Spaces must be used to indent lines; tabs are not allowed
Open

    public $search_fields = [

Spaces must be used to indent lines; tabs are not allowed
Open

        'File Name' => ['notes' => 'filename'],

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    public $list_fields_name = [

Spaces must be used to indent lines; tabs are not allowed
Open

        'File Name' => 'filename',

Spaces must be used to indent lines; tabs are not allowed
Open

        $relTables = [];

Spaces must be used to indent lines; tabs are not allowed
Open

            return $relTables;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string

Spaces must be used to indent lines; tabs are not allowed
Open

     * Mandatory table for supporting custom fields.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    // This is used to retrieve related vtiger_fields from form posts.

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        'Assigned To' => ['crmentity' => 'smownerid'],

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

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int $folderId

Line exceeds 120 characters; contains 155 characters
Open

    public $tab_name_index = ['vtiger_crmentity' => 'crmid', 'vtiger_notes' => 'notesid', 'vtiger_senotesrel' => 'notesid', 'vtiger_notescf' => 'notesid'];

Spaces must be used to indent lines; tabs are not allowed
Open

    ];

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getFolderDefault()

Spaces must be used to indent lines; tabs are not allowed
Open

    public $tab_name = ['vtiger_crmentity', 'vtiger_notes', 'vtiger_notescf'];

Spaces must be used to indent lines; tabs are not allowed
Open

    public $search_fields_name = [];

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

    public $table_index = 'notesid';

Spaces must be used to indent lines; tabs are not allowed
Open

    public $customFieldTable = ['vtiger_notescf', 'notesid'];

Spaces must be used to indent lines; tabs are not allowed
Open

    public $default_sort_order = 'DESC';

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new \App\Db\Query())->select(['tree', 'name'])->from('vtiger_trees_templates_data')->innerJoin('vtiger_field', 'vtiger_trees_templates_data.templateid = vtiger_field.fieldparams')->where(['vtiger_field.columnname' => 'folderid', 'vtiger_field.tablename' => 'vtiger_notes', 'vtiger_trees_templates_data.name' => 'Default'])->scalar();

Spaces must be used to indent lines; tabs are not allowed
Open

        'Modified Time' => 'modifiedtime',

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public $table_name = 'vtiger_notes';

Spaces must be used to indent lines; tabs are not allowed
Open

    public $old_filename = '';

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the relation tables for related modules.

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Line exceeds 120 characters; contains 132 characters
Open

        return (new \App\Db\Query())->select(['tree'])->from('vtiger_trees_templates_data')->where(['tree' => $folderId])->exists();

Spaces must be used to indent lines; tabs are not allowed
Open

        'Title' => 'notes_title',

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public $additional_column_fields = ['', '', '', ''];

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new \App\Db\Query())->select(['tree'])->from('vtiger_trees_templates_data')->where(['tree' => $folderId])->exists();

Spaces must be used to indent lines; tabs are not allowed
Open

        'Assigned To' => 'assigned_user_id',

Line exceeds 120 characters; contains 155 characters
Open

    public $mandatory_fields = ['notes_title', 'createdtime', 'modifiedtime', 'filename', 'filesize', 'filetype', 'filedownloadcount', 'assigned_user_id'];

Spaces must be used to indent lines; tabs are not allowed
Open

    public $default_order_by = '';

Spaces must be used to indent lines; tabs are not allowed
Open

    public function setRelationTables($secmodule = false)

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check the existence of folder by folderid.

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    public $column_fields = [];

Spaces must be used to indent lines; tabs are not allowed
Open

    public $relationFields = [];

Spaces must be used to indent lines; tabs are not allowed
Open

        'Folder Name' => ['attachmentsfolder' => 'foldername'],

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isFolderPresent($folderId)

Spaces must be used to indent lines; tabs are not allowed
Open

     * @var string[] List of fields in the RelationListView

Spaces must be used to indent lines; tabs are not allowed
Open

        'Title' => ['notes' => 'notes_title'],

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool|string $secmodule secondary module name

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false === $secmodule) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return $relTables[$secmodule];

Spaces must be used to indent lines; tabs are not allowed
Open

        'Folder Name' => 'folderid',

Spaces must be used to indent lines; tabs are not allowed
Open

    public $mandatory_fields = ['notes_title', 'createdtime', 'modifiedtime', 'filename', 'filesize', 'filetype', 'filedownloadcount', 'assigned_user_id'];

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get Folder Default.

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    public $tab_name_index = ['vtiger_crmentity' => 'crmid', 'vtiger_notes' => 'notesid', 'vtiger_senotesrel' => 'notesid', 'vtiger_notescf' => 'notesid'];

Spaces must be used to indent lines; tabs are not allowed
Open

    ];

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

Line exceeds 120 characters; contains 349 characters
Open

        return (new \App\Db\Query())->select(['tree', 'name'])->from('vtiger_trees_templates_data')->innerJoin('vtiger_field', 'vtiger_trees_templates_data.templateid = vtiger_field.fieldparams')->where(['vtiger_field.columnname' => 'folderid', 'vtiger_field.tablename' => 'vtiger_notes', 'vtiger_trees_templates_data.name' => 'Default'])->scalar();

There are no issues that match your filters.

Category
Status