YetiForceCompany/YetiForceCRM

View on GitHub
modules/Contacts/models/Record.php

Summary

Maintainability
C
7 hrs
Test Coverage
F
0%

Method getRecordRelatedListViewLinksLeftSide has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)
    {
        $links = parent::getRecordRelatedListViewLinksLeftSide($viewModel);
        if (\App\Mail::checkMailClient()) {
            if (\App\Mail::checkInternalMailClient()) {
Severity: Minor
Found in modules/Contacts/models/Record.php - About 1 hr to fix

    Function getRecordRelatedListViewLinksLeftSide has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)
        {
            $links = parent::getRecordRelatedListViewLinksLeftSide($viewModel);
            if (\App\Mail::checkMailClient()) {
                if (\App\Mail::checkInternalMailClient()) {
    Severity: Minor
    Found in modules/Contacts/models/Record.php - About 45 mins to fix

    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

    Avoid using static access to class '\App\Mail' in method 'getRecordRelatedListViewLinksLeftSide'.
    Open

                if (\App\Mail::checkInternalMailClient()) {
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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

    The method getRecordRelatedListViewLinksLeftSide uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $urldata = OSSMail_Module_Model::getExternalUrl($this->getModuleName(), $this->getId(), 'Detail', 'new');
                    if ($urldata && 'mailto:?' !== $urldata) {
                        $links[] = Vtiger_Link_Model::getInstanceFromValues([
                            'linklabel' => 'LBL_CREATEMAIL',
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    Avoid using static access to class 'OSSMail_Module_Model' in method 'getRecordRelatedListViewLinksLeftSide'.
    Open

                    $urldata = OSSMail_Module_Model::getExternalUrl($this->getModuleName(), $this->getId(), 'Detail', 'new');
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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 'getRecordRelatedListViewLinksLeftSide'.
    Open

                        $links[] = Vtiger_Link_Model::getInstanceFromValues([
                            'linklabel' => 'LBL_CREATEMAIL',
                            'linkhref' => true,
                            'linkurl' => $urldata,
                            'linkicon' => 'fas fa-envelope',
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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 'OSSMail_Module_Model' in method 'getRecordRelatedListViewLinksLeftSide'.
    Open

                        'linkurl' => OSSMail_Module_Model::getComposeUrl($this->getModuleName(), $this->getId(), 'Detail', 'new'),
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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\Mail' in method 'getRecordRelatedListViewLinksLeftSide'.
    Open

            if (\App\Mail::checkMailClient()) {
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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 'CRMEntity' in method 'getHierarchy'.
    Open

            $focus = CRMEntity::getInstance($this->getModuleName());
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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_Record_Model' in method 'getHierarchy'.
    Open

                    $recordModel = Vtiger_Record_Model::getCleanInstance($this->getModuleName());
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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 'getRecordRelatedListViewLinksLeftSide'.
    Open

                    $links['LBL_SEND_EMAIL'] = Vtiger_Link_Model::getInstanceFromValues([
                        'linklabel' => 'LBL_SEND_EMAIL',
                        'linkhref' => true,
                        'linkurl' => OSSMail_Module_Model::getComposeUrl($this->getModuleName(), $this->getId(), 'Detail', 'new'),
                        'linkicon' => 'fas fa-envelope',
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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

    Call to undeclared method \CRMEntity::getHierarchy
    Open

            $hierarchy = $focus->getHierarchy($this->getId());
    Severity: Critical
    Found in modules/Contacts/models/Record.php by phan

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function getHierarchy()
        {
            $focus = CRMEntity::getInstance($this->getModuleName());
            $hierarchy = $focus->getHierarchy($this->getId());
            foreach ($hierarchy['entries'] as $competitionId => $data) {
    Severity: Major
    Found in modules/Contacts/models/Record.php and 1 other location - About 5 hrs to fix
    modules/Partners/models/Record.php on lines 19..35

    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 201.

    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

    Further Reading

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

    class Contacts_Record_Model extends Vtiger_Record_Model

    The class Contacts_Record_Model is not named in CamelCase.
    Open

    class Contacts_Record_Model extends Vtiger_Record_Model
    {
        /** {@inheritdoc} */
        public function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)
        {
    Severity: Minor
    Found in modules/Contacts/models/Record.php by phpmd

    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

            if (\App\Mail::checkMailClient()) {

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

                            'linkclass' => 'btn-sm btn-default',

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

         * Function returns the details of IStorages Hierarchy.

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

                if (!empty($matches)) {

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

        {

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

                            'relatedModuleName' => 'OSSMailView',

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

                }

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

            foreach ($hierarchy['entries'] as $competitionId => $data) {

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

                    $urldata = OSSMail_Module_Model::getExternalUrl($this->getModuleName(), $this->getId(), 'Detail', 'new');

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

                    if ($urldata && 'mailto:?' !== $urldata) {

    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

                        'linkurl' => OSSMail_Module_Model::getComposeUrl($this->getModuleName(), $this->getId(), 'Detail', 'new'),

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

            $hierarchy = $focus->getHierarchy($this->getId());

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

            $links = parent::getRecordRelatedListViewLinksLeftSide($viewModel);

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

                            'linkurl' => $urldata,

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

                preg_match('/<a href="+/', $data[0], $matches);

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

                    $recordModel = Vtiger_Record_Model::getCleanInstance($this->getModuleName());

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

                } else {

    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

            return $hierarchy;

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

        }

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

        /** {@inheritdoc} */

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

                            'linklabel' => 'LBL_CREATEMAIL',

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

                    $recordModel->setId($competitionId);

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

                    $hierarchy['entries'][$competitionId][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] .

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

                        'linktarget' => '_blank',

    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

                        '</a>';

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

         * @return array

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

                    preg_match('/<a(.*)>(.*)<\\/a>/i', $data[0], $name);

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

                        'linkclass' => 'btn-sm btn-default',

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

        public function getHierarchy()

    Line exceeds 120 characters; contains 144 characters
    Open

                    $hierarchy['entries'][$competitionId][0] = ($dashes[0] ?? '') . '<a href=' . $recordModel->getDetailViewUrl() . '>' . $name[2] .

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

                        'linkhref' => true,

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

                    ]);

    Line exceeds 120 characters; contains 121 characters
    Open

                    $urldata = OSSMail_Module_Model::getExternalUrl($this->getModuleName(), $this->getId(), 'Detail', 'new');

    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 function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)

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

                        'linklabel' => 'LBL_SEND_EMAIL',

    Line exceeds 120 characters; contains 126 characters
    Open

                        'linkurl' => OSSMail_Module_Model::getComposeUrl($this->getModuleName(), $this->getId(), 'Detail', 'new'),

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

                    preg_match('/[.\s]+/', $data[0], $dashes);

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

                if (\App\Mail::checkInternalMailClient()) {

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

                        'linkicon' => 'fas fa-envelope',

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

                            'linkicon' => 'fas fa-envelope',

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

            return $links;

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

            $focus = CRMEntity::getInstance($this->getModuleName());

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

                    $links['LBL_SEND_EMAIL'] = Vtiger_Link_Model::getInstanceFromValues([

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

                        $links[] = Vtiger_Link_Model::getInstanceFromValues([

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

                            'linkhref' => true,

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

            }

    Class name "Contacts_Record_Model" is not in camel caps format
    Open

    class Contacts_Record_Model extends Vtiger_Record_Model

    There are no issues that match your filters.

    Category
    Status