modules/Vtiger/models/JsScript.php
Remove error control operator '@' on line 43. Open
Open
public function getSrc()
{
$src = $this->get('src');
if (empty($src)) {
$src = $this->get('linkurl');
- Read upRead up
- Exclude checks
ErrorControlOperator
Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.
Example
function foo($filePath) {
$file = @fopen($filPath); // hides exceptions
$key = @$array[$notExistingKey]; // assigns null to $key
}
Source http://phpmd.org/rules/cleancode.html#errorcontroloperator
Avoid assigning values to variables in if clauses and the like (line '43', column '29'). Open
Open
public function getSrc()
{
$src = $this->get('src');
if (empty($src)) {
$src = $this->get('linkurl');
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class Vtiger_JsScript_Model extends \App\Base
- Exclude checks
The class Vtiger_JsScript_Model is not named in CamelCase. Open
Open
class Vtiger_JsScript_Model extends \App\Base
{
const DEFAULT_TYPE = 'text/javascript';
/**
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Avoid variables with short names like $fs. Configured minimum length is 3. Open
Open
if ($this->has('base') && $fs = @filemtime($this->get('base'))) {
- Read upRead up
- Exclude checks
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
Open
* Function to get the src attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$src = $this->get('linkurl');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return Vtiger_JsScript_Model instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getType()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Static Function to get an instance of Vtiger JsScript Model from a given vtlib\Link object.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public static function getInstanceFromLinkObject(vtlib\Link $linkObj)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ($objectProperties as $properName => $propertyValue) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $linkModel->setData($objectProperties);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (empty($type)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$src = $src . '?s=' . $fs;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$objectProperties = get_object_vars($linkObj);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$linkModel = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @param vtlib\Link $linkObj
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
const DEFAULT_TYPE = 'text/javascript';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if (empty($src)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$linkModel->{$properName} = $propertyValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $src;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Function to get the type attribute value.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$src = $this->get('src');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function getSrc()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$type = $this->get('type');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$type = self::DEFAULT_TYPE;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($this->has('base') && $fs = @filemtime($this->get('base'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Class name "Vtiger_JsScript_Model" is not in camel caps format Open
Open
class Vtiger_JsScript_Model extends \App\Base
- Exclude checks