Showing 86 of 86 total issues
File admin_controller.php
has 405 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
*
* Board Rules extension for the phpBB Forum Software package.
*
Method add_edit_rule_data
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function add_edit_rule_data($entity, $data)
{
// Get form's POST actions (submit or preview)
$submit = $this->request->is_set_post('submit');
$preview = $this->request->is_set_post('preview');
Function add_edit_rule_data
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
protected function add_edit_rule_data($entity, $data)
{
// Get form's POST actions (submit or preview)
$submit = $this->request->is_set_post('submit');
$preview = $this->request->is_set_post('preview');
- 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
The class rule has 14 public methods. Consider refactoring rule to keep number of public methods under 10. Open
class rule implements rule_interface
{
/**
* Data for this entity
*
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class rule has an overall complexity of 67 which is very high. The configured complexity threshold is 50. Open
class rule implements rule_interface
{
/**
* Data for this entity
*
- Exclude checks
rule
has 28 functions (exceeds 20 allowed). Consider refactoring. Open
class rule implements rule_interface
{
/**
* Data for this entity
*
The class admin_controller has an overall complexity of 65 which is very high. The configured complexity threshold is 50. Open
class admin_controller implements admin_interface
{
/** @var \phpbb\config\config */
protected $config;
- Exclude checks
Method display
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function display()
{
// When board rules are disabled, redirect users back to the forum index
if (empty($this->config['boardrules_enable']))
{
File rule.php
has 280 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
*
* Board Rules extension for the phpBB Forum Software package.
*
Method main
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function main($id, $mode)
{
global $phpbb_container;
/** @var \phpbb\language\language $lang */
Function display
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function display()
{
// When board rules are disabled, redirect users back to the forum index
if (empty($this->config['boardrules_enable']))
{
- 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 import
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function import($data)
{
// Clear out any saved data
$this->data = array();
Avoid excessively long variable names like $message_parse_options. Keep variable name length under 20. Open
$message_parse_options = array(
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $boardrules_list_style. Keep variable name length under 20. Open
$boardrules_list_style = $this->request->variable('boardrules_list_style', '');
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct(\phpbb\config\config $config, ContainerInterface $container, \phpbb\controller\helper $controller_helper, \phpbb\db\driver\driver_interface $db, \phpbb\language\language $lang, \phpbb\log\log $log, \phpbb\notification\manager $notification_manager, \phpbb\request\request $request, \phpbb\boardrules\operators\rule $rule_operator, \phpbb\template\template $template, \phpbb\user $user, $root_path, $php_ext)
Function main
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function main($id, $mode)
{
global $phpbb_container;
/** @var \phpbb\language\language $lang */
- 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 display_rules
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function display_rules($language, $parent_id = 0)
{
// Grab all the rules in the current user's language
$entities = $this->rule_operator->get_rules($language, $parent_id);
Method display_options
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function display_options()
{
// Create a form key for preventing CSRF attacks
add_form_key('boardrules_settings');
Method insert_sample_rule_data
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function insert_sample_rule_data()
{
/** @var \phpbb\user $user */
$user = $this->container->get('user');
Method set_anchor
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set_anchor($anchor)
{
// Enforce a string
$anchor = (string) $anchor;