YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
55 mins
Test Coverage
F
0%

Function getRssClient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getRssClient(string $url): SimplePie
    {
        $feed = new SimplePie();
        if (!empty(\Config\Security::$proxyConnection)) {
            $proxy = [];
Severity: Minor
Found in modules/Rss/models/Record.php - About 55 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

Missing class import via use statement (line '208', column '20').
Open

        $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->where(['starred' => 1])->scalar();
Severity: Minor
Found in modules/Rss/models/Record.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 '148', column '19').
Open

        $rowData = (new \App\Db\Query())->from('vtiger_rss')->where(['rssid' => $recordId])->one();
Severity: Minor
Found in modules/Rss/models/Record.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 '226', column '15').
Open

        $feed = new SimplePie();
Severity: Minor
Found in modules/Rss/models/Record.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 '190', column '15').
Open

        $feed = new SimplePie();
Severity: Minor
Found in modules/Rss/models/Record.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 '212', column '21').
Open

            $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->scalar();
Severity: Minor
Found in modules/Rss/models/Record.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

Avoid assigning values to variables in if clauses and the like (line '197', column '7').
Open

    public function validateRssUrl($url)
    {
        $feed = new SimplePie();
        $feed->set_cache_location(ROOT_DIRECTORY . '/cache/rss_cache');
        $feed->set_feed_url($url);
Severity: Minor
Found in modules/Rss/models/Record.php by phpmd

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 '\App\Purifier' in method 'setRssChannel'.
Open

        $this->set('rsstitle', App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($rss->get_title()))));
Severity: Minor
Found in modules/Rss/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\Purifier' in method 'setRssItems'.
Open

            $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));
Severity: Minor
Found in modules/Rss/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\Validator' in method 'setRssChannel'.
Open

        if (\App\Validator::url($rss->get_link())) {
Severity: Minor
Found in modules/Rss/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 assigning values to variables in if clauses and the like (line '158', column '14').
Open

    public static function getInstanceById($recordId, $qualifiedModuleName = null)
    {
        $rowData = (new \App\Db\Query())->from('vtiger_rss')->where(['rssid' => $recordId])->one();
        if ($rowData) {
            $recordModel = new self();
Severity: Minor
Found in modules/Rss/models/Record.php by phpmd

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 '\App\TextUtils' in method 'setRssItems'.
Open

                'title' => \App\TextUtils::textTruncate($title, 100),
Severity: Minor
Found in modules/Rss/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\Purifier' in method 'setRssChannel'.
Open

            $this->set('url', \App\Purifier::purifyByType($rss->get_link(), \App\Purifier::URL));
Severity: Minor
Found in modules/Rss/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\Purifier' in method 'setRssItems'.
Open

                'link' => App\Purifier::decodeHtml($announcement->get_link()),
Severity: Minor
Found in modules/Rss/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\Fields\DateTime' in method 'setRssItems'.
Open

                'date' => \App\Fields\DateTime::formatToViewDate($announcement->get_date('Y-m-d H:i:s')),
Severity: Minor
Found in modules/Rss/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\Purifier' in method 'setRssChannel'.
Open

        $this->set('rsstitle', App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($rss->get_title()))));
Severity: Minor
Found in modules/Rss/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\Log' in method 'getInstanceById'.
Open

                \App\Log::warning($error, 'RSS');
Severity: Minor
Found in modules/Rss/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\Purifier' in method 'setRssItems'.
Open

            $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));
Severity: Minor
Found in modules/Rss/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\Db' in method 'saveRecord'.
Open

        $db = \App\Db::getInstance();
Severity: Minor
Found in modules/Rss/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 getDefaultRss uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->scalar();
            $this->setId($recordId);
        }
Severity: Minor
Found in modules/Rss/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 'App\Purifier' in method 'setRssChannel'.
Open

        $this->set('rsstitle', App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($rss->get_title()))));
Severity: Minor
Found in modules/Rss/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\Purifier' in method 'setRssItems'.
Open

            $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));
Severity: Minor
Found in modules/Rss/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\Validator' in method 'setRssItems'.
Open

            if (!\App\Validator::url((string) $announcement->get_link())) {
Severity: Minor
Found in modules/Rss/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\Log' in method 'validateRssUrl'.
Open

            \App\Log::warning($error, 'RSS');
Severity: Minor
Found in modules/Rss/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

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

        $dbCommand->update('vtiger_rss', ['starred' => 0])->execute();
Severity: Critical
Found in modules/Rss/models/Record.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 "rsstitle" 3 times.
Open

        return $this->get('rsstitle');
Severity: Critical
Found in modules/Rss/models/Record.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 "rssid" 7 times.
Open

        return $this->get('rssid');
Severity: Critical
Found in modules/Rss/models/Record.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_rss" 7 times.
Open

        $insert = $db->createCommand()->insert('vtiger_rss', ['rssurl' => $url, 'rsstitle' => $title])->execute();
Severity: Critical
Found in modules/Rss/models/Record.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 method error from undeclared class \SimplePie
Open

        if ($error = $feed->error()) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method set_feed_url from undeclared class \SimplePie
Open

        $feed->set_feed_url($url);
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method get_items from undeclared class \SimplePie
Open

        foreach ($rss->get_items() as $announcement) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method get_link from undeclared class \SimplePie
Open

        if (\App\Validator::url($rss->get_link())) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to undeclared method \App\Db::createCommand
Open

        $dbCommand = \App\Db::getInstance()->createCommand();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Parameter $rss has undeclared type \SimplePie
Open

    public function setRssItems(SimplePie $rss): void
Severity: Minor
Found in modules/Rss/models/Record.php by phan

Call to method get_link from undeclared class \SimplePie
Open

            $this->set('url', \App\Purifier::purifyByType($rss->get_link(), \App\Purifier::URL));
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to undeclared method \App\Db::createCommand
Open

        \App\Db::getInstance()->createCommand()->delete('vtiger_rss', ['rssid' => $this->getId()])->execute();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method set_cache_location from undeclared class \SimplePie
Open

        $feed->set_cache_location(ROOT_DIRECTORY . '/cache/rss_cache');
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method url from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
Open

        if (\App\Validator::url($rss->get_link())) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Returning type false but getInstanceById() is declared to return \Rss_Record_Model
Open

        return false;
Severity: Minor
Found in modules/Rss/models/Record.php by phan

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

            $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->scalar();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method get_title from undeclared class \SimplePie
Open

        $this->set('rsstitle', App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($rss->get_title()))));
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method init from undeclared class \SimplePie
Open

            if ($feed->init()) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method warning from undeclared class \App\Log
Open

                \App\Log::warning($error, 'RSS');
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Return type of getRssClient() is undeclared type \SimplePie
Open

    public static function getRssClient(string $url): SimplePie
Severity: Minor
Found in modules/Rss/models/Record.php by phan

Parameter $rss has undeclared type \SimplePie
Open

    public function setRssChannel(SimplePie $rss): void
Severity: Minor
Found in modules/Rss/models/Record.php by phan

Call to undeclared method \App\Db::createCommand
Open

        $insert = $db->createCommand()->insert('vtiger_rss', ['rssurl' => $url, 'rsstitle' => $title])->execute();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Declaration of function getCleanInstance($qualifiedModuleName) should be compatible with function getCleanInstance(string $moduleName) (parameter #1 with no type cannot replace original parameter with type 'string') defined in /code/modules/Vtiger/models/Record.php:734
Open

     * @param string $qualifiedModuleName
Severity: Minor
Found in modules/Rss/models/Record.php by phan

Call to method __construct from undeclared class \SimplePie
Open

        $feed = new SimplePie();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method warning from undeclared class \App\Log
Open

            \App\Log::warning($error, 'RSS');
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method __construct from undeclared class \SimplePie
Open

        $feed = new SimplePie();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method set_cache_location from undeclared class \SimplePie
Open

        $feed->set_cache_location(ROOT_DIRECTORY . '/cache/rss_cache');
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Argument 1 (value) is string but \Rss_Record_Model::setId() takes int defined at /code/modules/Rss/models/Record.php:31
Open

            $this->setId($id);
Severity: Minor
Found in modules/Rss/models/Record.php by phan

Call to method error from undeclared class \SimplePie
Open

            } elseif ($error = $feed->error()) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method init from undeclared class \SimplePie
Open

        if ($feed->init()) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

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

        $rowData = (new \App\Db\Query())->from('vtiger_rss')->where(['rssid' => $recordId])->one();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method set_feed_url from undeclared class \SimplePie
Open

        $feed->set_feed_url($url);
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method set_curl_options from undeclared class \SimplePie
Open

            $feed->set_curl_options($proxy);
Severity: Critical
Found in modules/Rss/models/Record.php by phan

Call to method url from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
Open

            if (!\App\Validator::url((string) $announcement->get_link())) {
Severity: Critical
Found in modules/Rss/models/Record.php by phan

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

        $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->where(['starred' => 1])->scalar();
Severity: Critical
Found in modules/Rss/models/Record.php by phan

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

class Rss_Record_Model extends Vtiger_Record_Model

Avoid variables with short names like $db. Configured minimum length is 3.
Open

        $db = \App\Db::getInstance();
Severity: Minor
Found in modules/Rss/models/Record.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

The class Rss_Record_Model is not named in CamelCase.
Open

class Rss_Record_Model extends Vtiger_Record_Model
{
    /**
     * Function to get the id of the Record.
     *
Severity: Minor
Found in modules/Rss/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

Avoid variables with short names like $id. Configured minimum length is 3.
Open

            $id = $db->getLastInsertID('vtiger_rss_rssid_seq');
Severity: Minor
Found in modules/Rss/models/Record.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

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

        return $this->get('rssid');

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

    public function getRssItems(): array

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

     * Function to get Rss fetched object.

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 id of the Record.

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

        return $this->get('rsstitle');

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

     * @return array

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 setRssItems(SimplePie $rss): void

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 setId($value)

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

        $items = [];

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 int - Report 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

     * Function to set the id of the Record.

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

        return $this->set('rssid', $value);

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

    public function getName(): string

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 getId()

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

     *

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

     * @param SimplePie $rss - Rss fetched object

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

    {

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

            if (!\App\Validator::url((string) $announcement->get_link())) {

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

                continue;

Line exceeds 120 characters; contains 123 characters
Open

            $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_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

            $this->set('url', \App\Purifier::purifyByType($rss->get_link(), \App\Purifier::URL));

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 $id;

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

        $dbCommand->update('vtiger_rss', ['starred' => 1], ['rssid' => $recordId])->execute();

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

        $db = \App\Db::getInstance();

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

     * Function to delete a record.

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

        $recordId = $this->getId();

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

    {

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

            $recordModel = new self();

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

            if ($feed->init()) {

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

     * @return Rss_Record_Model

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

        $feed = new SimplePie();

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

        $feed->set_cache_location(ROOT_DIRECTORY . '/cache/rss_cache');

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

    public function getDefaultRss()

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

        $rowData = (new \App\Db\Query())->from('vtiger_rss')->where(['rssid' => $recordId])->one();

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

                $recordModel->set('error', $error);

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

    /**

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

                'date' => \App\Fields\DateTime::formatToViewDate($announcement->get_date('Y-m-d H:i:s')),

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

     * @param string $url

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

    public function saveRecord($url)

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

        $title = $this->getName();

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

        $dbCommand->update('vtiger_rss', ['starred' => 0])->execute();

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

    public static function getInstanceById($recordId, $qualifiedModuleName = null)

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

            $recordModel->setData($rowData);

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

        return false;

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

                'link' => App\Purifier::decodeHtml($announcement->get_link()),

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 save the record.

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

            $title = $url;

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

        $insert = $db->createCommand()->insert('vtiger_rss', ['rssurl' => $url, 'rsstitle' => $title])->execute();

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

    }

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

        \App\Db::getInstance()->createCommand()->delete('vtiger_rss', ['rssid' => $this->getId()])->execute();

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

                'fullTitle' => $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

    /**

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

     * Function to validate the rss url.

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

    /**

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

        $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->where(['starred' => 1])->scalar();

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

     * @return SimplePie

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

     * Function to get the Name of the record.

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

     * Function to set Rss Object.

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

     * @return void

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 $this->get('rss') ?: [];

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

     * @param int $value - id value

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

     * @return Rss_Record_Model - current instance

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

     * @return string - Entity Name of the record

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

        foreach ($rss->get_items() as $announcement) {

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

     * Function to make a record default for an rss record.

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

        $dbCommand = \App\Db::getInstance()->createCommand();

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

     * @param int    $recordId

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

        if ($rowData) {

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

            } elseif ($error = $feed->error()) {

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 static function getCleanInstance($qualifiedModuleName)

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

     *

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

     * Get rss client.

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

     *

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

            $proxy = [];

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

        $feed->set_feed_url($url);

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 delete()

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

     * @param string $qualifiedModuleName

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

            $this->setRssChannel($feed);

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

     */

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

        if ($recordId) {

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

                    $login .= ':' . \Config\Security::$proxyPassword;

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

        $feed->set_cache_location(ROOT_DIRECTORY . '/cache/rss_cache');

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

                'title' => \App\TextUtils::textTruncate($title, 100),

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

     * Function to set Rss values.

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

    {

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

                }

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

     */

Line exceeds 120 characters; contains 125 characters
Open

        $this->set('rsstitle', App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($rss->get_title()))));

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

     * Function to get record instance by using id and moduleName.

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

     * Function to get clean record instance by using moduleName.

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

        return $recordModel->setModule($qualifiedModuleName);

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

     * Function to get the default rss.

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

                $login = \Config\Security::$proxyLogin ?? '';

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

        }

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

            if (!empty(\Config\Security::$proxyPort)) {

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

            $items[] = [

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

        $this->set('rsstitle', App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($rss->get_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

    {

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 $recordModel;

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

    public function validateRssUrl($url)

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

                if (!empty(\Config\Security::$proxyPassword)) {

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

        if (\App\Validator::url($rss->get_link())) {

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

            $id = $db->getLastInsertID('vtiger_rss_rssid_seq');

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

            $feed = self::getRssClient($recordModel->get('rssurl'));

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

     * @param string $qualifiedModuleName

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

     * @param string $url

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

        $feed->set_feed_url($url);

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

        }

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

                $proxy[CURLOPT_PROXYPORT] = \Config\Security::$proxyPort;

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

    }

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

     * @param SimplePie $rss - Rss fetched object

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

     *

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

        if ($insert) {

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 true;

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

        $feed = new SimplePie();

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->setId($id);

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

        return false;

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

            $recordModel->setModule($qualifiedModuleName);

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

                $recordModel->setRssChannel($feed);

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

    /**

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

        if ($error = $feed->error()) {

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

            \App\Log::warning($error, 'RSS');

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

            $this->setId($recordId);

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 Rss_Record_Model RecordModel

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

                \App\Log::warning($error, 'RSS');

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

            $recordId = (new \App\Db\Query())->select(['rssid'])->from('vtiger_rss')->scalar();

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

     */

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

            $feed->set_curl_options($proxy);

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

     * @return void

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

        if ('' === $title) {

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

    public function makeDefault()

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

                $recordModel->setRssItems($feed);

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

     *

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

        $recordModel = new self();

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

            $this->setId($recordId);

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

     * @param string $url

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

    public static function getRssClient(string $url): SimplePie

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

        if (!empty(\Config\Security::$proxyConnection)) {

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

            $title = App\Purifier::decodeHtml(\App\Purifier::purify(App\Purifier::decodeHtml($announcement->get_title())));

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

        $this->set('rss', $items);

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

    public function setRssChannel(SimplePie $rss): void

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

     *

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

        if ($feed->init()) {

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

        }

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

            $proxy[CURLOPT_PROXY] = \Config\Security::$proxyHost;

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

            if (!empty(\Config\Security::$proxyLogin) || !empty(\Config\Security::$proxyPassword)) {

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

                $proxy[CURLOPT_PROXYUSERPWD] = $login;

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

        return $feed;

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

class Rss_Record_Model extends Vtiger_Record_Model

There are no issues that match your filters.

Category
Status