Showing 597 of 597 total issues
Method getLogData
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getLogData(
Threema\MsgApi\Helpers\ReceiveMessageResult $receiveResult,
Threema\MsgApi\Messages\ThreemaMessage $threemaMsg
) {
$eol = PHP_EOL;
Avoid using undefined variables such as '$cryptTool' which will lead to PHP notices. Open
$this->cryptTool = $cryptTool;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$error' which will lead to PHP notices. Open
throw new XenForo_Exception($error);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$error' which will lead to PHP notices. Open
if (!self::meetsRequirements($error)) {
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method _getExistingData
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _getExistingData($data)
{
// try primary key first
/** @var string $requestId */
if ($requestId = $this->_getExistingPrimaryKey($data, 'request_id')) {
Method queryCredits
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function queryCredits(array &$status, array &$extraError)
{
/** @var ThreemaGateway_Handler_Permissions $permissions */
$permissions = ThreemaGateway_Handler_Permissions::getInstance();
Function ReceiveCallback
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var ReceiveCallback = (function () {
'use strict';
var me = {};
var $inputElem;
var $hiddenElem;
Method checkForReceiverCode
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function checkForReceiverCode(ThreemaGateway_Handler_Action_Callback $handler,
Threema\MsgApi\Helpers\ReceiveMessageResult $receiveResult,
Threema\MsgApi\Messages\ThreemaMessage $threemaMsg,
&$output,
&$saveMessage,
Method checkTecRequire
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function checkTecRequire(array &$status, array &$extraError)
{
// optional check: HTTPS
if (!XenForo_Application::$secure) {
$extraError[]['text'] = new XenForo_Phrase('option_threema_gateway_status_no_https');
Function processPending
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function processPending(array $processOptions = [])
{
if (!$this->pendingRequests) {
$this->preProcessPending();
}
- Read upRead up
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
Function getMessageMetaData
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getMessageMetaData($groupById = false, $ignoreInvalid = true)
{
/** @var array $limitOptions */
$limitOptions = $this->prepareLimitFetchOptions($this->fetchOptions);
- Read upRead up
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
Function getRandomBytes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function getRandomBytes($number)
{
/** @var string $output */
$output = '';
- Read upRead up
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
Method validatePreConditions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validatePreConditions(&$errorString)
{
/** @var XenForo_Options $options */
$options = XenForo_Application::getOptions();
Method uninstall
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function uninstall()
{
// delete throttle table
/** @var ThreemaGateway_Installer_ActionThrottle $throttleInstaller */
$throttleInstaller = new ThreemaGateway_Installer_ActionThrottle;
Method validateRequest
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validateRequest(&$errorString)
{
// access token validation (authentication of Gateway server)
/** @var XenForo_Options $options */
$options = XenForo_Application::getOptions();
Consider simplifying this complex logical expression. Open
if (!$this->input->inRequest('from') ||
!$this->input->inRequest('to') ||
!$this->input->inRequest('messageId') ||
!$this->input->inRequest('date') ||
!$this->input->inRequest('nonce') ||
Function actionTwoStepEnable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function actionTwoStepEnable()
{
/** @var XenForo_ControllerResponse_View $parent */
$parent = parent::actionTwoStepEnable();
- Read upRead up
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
Function triggerVerification
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function triggerVerification($context, array $user, $userIp, array &$providerData)
{
parent::triggerVerification($context, $user, $userIp, $providerData);
// this 2FA mode requires end-to-end encryption
- Read upRead up
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 variables with short names like $db. Configured minimum length is 3. Open
$db = XenForo_Application::get('db');
- 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
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = XenForo_Application::get('db');
- 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;
}
}
}