Showing 597 of 597 total issues
File Callback.php
has 286 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Allows XenForo to receive Threema messages by providing a callback.
*
* @package ThreemaGateway
ThreemaGateway_Handler_Action_TfaCallback_Abstract
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class ThreemaGateway_Handler_Action_TfaCallback_Abstract extends ThreemaGateway_Handler_Action_Abstract
{
/**
* @var array Cache of models
*/
Method handleManage
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
final public function handleManage(XenForo_Controller $controller, array $user, array $providerData)
{
$this->gatewayPermissions->setUserId($user);
/** @var XenForo_Input $input */
Method handleMessageDecline
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleMessageDecline(array &$providerData, array $user, $userIp = null)
{
/** @var XenForo_Options $xenOptions */
$xenOptions = XenForo_Application::getOptions();
/** @var int $blockingTime seconds how long users should be blocked */
Function handleManage
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
final public function handleManage(XenForo_Controller $controller, array $user, array $providerData)
{
$this->gatewayPermissions->setUserId($user);
/** @var XenForo_Input $input */
- 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 create
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create()
{
$db = XenForo_Application::get('db');
// set charset
Method setDataForRequest
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function setDataForRequest(
array $confirmRequest,
array $setData,
array $processOptions = []
) {
Method processMessage
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function processMessage($downloadPath, $debugMode = false)
{
/** @var string $output */
$output = '';
Function getMessageDataByType
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function getMessageDataByType($messageType, $includeMetaData = true)
{
/** @var array $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 triggerVerification
has 46 lines of code (exceeds 25 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
Method _getExistingData
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _getExistingData($data)
{
/** @var string $messageId */
if (!$messageId = $this->_getExistingPrimaryKey($data, 'message_id')) {
return false;
Method _preSave
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function _preSave()
{
// filter data
// also uses existing data as a data base as otherwise the main table
// may also get deleted because of missing message id
Method install
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function install($installedAddon)
{
/** @var array $providerInstaller An array with the models of all providers */
$providerInstaller = self::getProviderInstaller();
// check requirements of Gateway
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
/**
* Passes data to Tfa model.
*
* @package ThreemaGateway
- Read upRead up
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 115.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
/**
* Passes data to Tfa model.
*
* @package ThreemaGateway
- Read upRead up
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 115.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method verifyFromInput
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function verifyFromInput($context, XenForo_Input $input, array $user, array &$providerData)
{
/** @var bool $result from parent, for error checking */
$result = parent::verifyFromInput($context, $input, $user, $providerData);
Avoid excessively long class names like ThreemaGateway_Model_TfaPendingMessagesConfirmation. Keep class name length under 40. Open
class ThreemaGateway_Model_TfaPendingMessagesConfirmation extends XenForo_Model
{
/**
* @var string database table name
*/
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Avoid excessively long class names like ThreemaGateway_Listener_TfaMessageCallback. Keep class name length under 40. Open
class ThreemaGateway_Listener_TfaMessageCallback
{
/**
* Presave listener: Checks whether text messages contain code used for the receiver 2FA.
*
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Avoid excessively long class names like ThreemaGateway_Option_ThreemaGatewaySecret. Keep class name length under 40. Open
class ThreemaGateway_Option_ThreemaGatewaySecret
{
/**
* @var int Chars not to censor when displaying secret
*/
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}
Source https://phpmd.org/rules/naming.html#longclassname
Avoid excessively long class names like ThreemaGateway_DataWriter_TfaPendingMessagesConfirmation. Keep class name length under 40. Open
class ThreemaGateway_DataWriter_TfaPendingMessagesConfirmation extends XenForo_DataWriter
{
/**
* Gets the fields that are defined for the table. See parent for explanation.
*
- Read upRead up
- Exclude checks
LongClassName
Since: 2.9
Detects when classes or interfaces are declared with excessively long names.
Example
class ATooLongClassNameThatHintsAtADesignProblem {
}
interface ATooLongInterfaceNameThatHintsAtADesignProblem {
}