Skip to content

Commit

Permalink
Dev Some Scrutinizer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Dec 12, 2017
1 parent e8f8efe commit f42a959
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ filter:
- 'application/libraries/admin/http/*'
- 'application/libraries/admin/pclzip/*'
- 'application/extensions/*'
- 'application/tests/*'
- 'application/third_party/*'
- 'third_party/*'
- 'installer/*'
Expand Down Expand Up @@ -55,6 +56,8 @@ tools:
- 'tmp/*'
- 'upload/*'
- 'tests/*'
- 'application/tests/*'

coding_style:
php:
braces:
Expand Down
2 changes: 1 addition & 1 deletion application/core/LSYii_Validators.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function xssFilter($value)
$aParsedExpressions = $oExpressionManager->Tokenize($sExpression, true);
foreach ($aParsedExpressions as $aParsedExpression) {
if ($aParsedExpression[2] == 'DQ_STRING') {
$sNewValue .= "\"".$filter->purify($aParsedExpression[0])."\""; // This disallow complex HTML construction with XSS
$sNewValue .= "\"".(string)$filter->purify($aParsedExpression[0])."\""; // This disallow complex HTML construction with XSS
} elseif ($aParsedExpression[2] == 'SQ_STRING') {
$sNewValue .= "'".$filter->purify($aParsedExpression[0])."'";
} else {
Expand Down
18 changes: 6 additions & 12 deletions application/core/plugins/ExportR/RDataWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,25 @@ protected function transformResponseValue($value, $fieldType, FormattingOptions
}

if ($value == 'Y') {
// Yes
// Yes
return 1;
} elseif ($value === '') {
// No
// No
return 0;
} else {
// Not shown
return $this->na;
}
break;
// Not shown
return $this->na;

case 'Y': // Yes no question
if ($value == 'Y') {
return 1;
} elseif ($value == 'N') {
return 2;
} else {
// No data, probably a hidden question
return $this->na;
}
break;

// No data, probably a hidden question
return $this->na;
default:
return $value;
break;
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/admin/export/CsvWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function outputRecord($headers, $values, FormattingOptions $oOptions)
}

// If we don't want headers in our csv, for example in exports like r/spss etc. we suppress the header by setting this switch in the init
if ($this->doHeaders == true) {
if ($this->doHeaders === true) {
$index = 0;
foreach ($headers as $header) {
$headers[$index] = $this->csvEscape($header);
Expand Down
3 changes: 0 additions & 3 deletions application/helpers/database_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,12 @@ function dbQuoteID($id)
case "mysqli" :
case "mysql" :
return "`".$id."`";
break;
case "dblib":
case "mssql" :
case "sqlsrv" :
return "[".$id."]";
break;
case "pgsql":
return "\"".$id."\"";
break;
default:
return $id;
}
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/globalsettings_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function injectglobalsettings()
}

/**
* Undocumented function
* Returns a global setting
*
* @param [type] $settingname
* @param string $settingname
* @return string
*/
function getGlobalSetting($settingname)
Expand Down
25 changes: 17 additions & 8 deletions application/libraries/MenuObjects/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class Menu implements MenuInterface
protected $iconClass = "";

/**
* @param array $options - Options for either dropdown menu or plain link
* @return ExtraMenu
*/
* @param array $options - Options for either dropdown menu or plain link
* @return void
*/
public function __construct($options)
{
if (isset($options['isDropDown'])) {
Expand All @@ -39,17 +39,26 @@ public function __construct($options)

public function isDropDown()
{
return $this->isDropDown; }
return $this->isDropDown;
}

public function getLabel()
{
return $this->label; }
return $this->label;
}

public function getHref()
{
return $this->href; }
return $this->href;
}

public function getMenuItems()
{
return $this->menuItems; }
return $this->menuItems;
}

public function getIconClass()
{
return $this->iconClass; }
return $this->iconClass;
}
}
2 changes: 1 addition & 1 deletion application/models/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function updateCFieldName($iSurveyID, $iQuestionID, $iOldGroupID, $iNewGr
{
$oResults = $this->findAllByAttributes(array('cqid'=>$iQuestionID));
foreach ($oResults as $oRow) {
$cfnregs = '';
$cfnregs = [];
if (preg_match('/(\S*?)'.$iSurveyID."X".$iOldGroupID."X".$iQuestionID."(.*)/", $oRow->cfieldname, $cfnregs) > 0) {
$sNewCfn = $cfnregs[1].$iSurveyID."X".$iNewGroupID."X".$iQuestionID.$cfnregs[2];
Yii::app()->db->createCommand()
Expand Down
2 changes: 1 addition & 1 deletion application/models/QuestionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private static function getQuestionIdsInGroup($groupId)
* @param string[] $order
* @return mixed
*/
function getAllGroups($condition, $order = false)
public function getAllGroups($condition, $order = false)
{
$command = Yii::app()->db->createCommand()
->where($condition)
Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
* @property bool $isShowProgress how progress bar
* @property bool $isNoKeyboard Show on-screen keyboard
* @property bool $isAllowEditAfterCompletion Allow multiple responses or update responses with one token
*
* @property SurveyLanguageSetting $defaultlanguage
* @method mixed active()
*/
class Survey extends LSActiveRecord
Expand Down
8 changes: 0 additions & 8 deletions application/models/SurveyURLParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ public function getParametersForSurvey($iSurveyID)
->query();
}

/**
* @param array $compareToArray
*/
public function compareToArray($compareToArray)
{

}

/**
* @param array $aConditions
* @return mixed
Expand Down

0 comments on commit f42a959

Please sign in to comment.