Showing 86 of 86 total issues
Missing class import via use statement (line '147', column '14'). Open
throw new \phpbb\boardrules\exception\out_of_bounds('rule_id');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method get_message_for_display has a boolean flag argument $censor_text, which is a certain sign of a Single Responsibility Principle violation. Open
public function get_message_for_display($censor_text = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '225', column '14'). Open
throw new \phpbb\boardrules\exception\out_of_bounds('rule_id');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '626', column '25'). Open
$json_response = new \phpbb\json_response;
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '44', column '19'). Open
$reparser = new \phpbb\boardrules\textreparser\plugins\rule_text(
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method set_message_option has a boolean flag argument $negate, which is a certain sign of a Single Responsibility Principle violation. Open
protected function set_message_option($option_value, $negate = false, $reparse_message = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '556', column '16'). Open
throw new \phpbb\boardrules\exception\unexpected_value(array('rule_language', 'WRONG_DATA_LANG', 'UNEXPECTED_VALUE'));
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '84', column '17'). Open
$helper = new \phpbb\boardrules\migrations\helper($this->db, $this->table_prefix);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method get_message_for_display has a boolean flag argument $censor_text, which is a certain sign of a Single Responsibility Principle violation. Open
public function get_message_for_display($censor_text = true);
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Function set_language
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function set_language($language)
{
if (!isset($this->data['rule_language']))
{
// Validate the requested language ISO is installed
- 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 method __construct has 13 parameters. Consider reducing the number of parameters to less than 10. 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)
{
$this->config = $config;
$this->container = $container;
$this->controller_helper = $controller_helper;
- Exclude checks
The method add_edit_rule_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
{
// Add a new rule entity to the database
try
{
$this->rule_operator->add_rule($entity, $data['rule_language'], $data['rule_parent_id']);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method display uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
{
// Rules
$is_category = false;
$anchor = $entity->get_anchor() ?: $this->lang->lang('BOARDRULES_RULE_ANCHOR', ($cat_counter - 1) . $rule_counter);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method display_language_selection uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
{
// If there is only one available language its index is 0
// and that language is the default board language.
// We do not need any loops here to get its iso code.
$this->display_rules($rows[0]['lang_iso']);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid unused parameters such as '$id'. Open
public function main($id, $mode)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
The method send_notification uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
{
// Request confirmation from the user to send notification to all users
// Build a hidden array of the form data
confirm_box(false, $this->lang->lang('ACP_BOARDRULES_NOTIFY_CONFIRM'), build_hidden_fields(array(
'action_send_notification' => true,
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method display() has 106 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function display()
{
// When board rules are disabled, redirect users back to the forum index
if (empty($this->config['boardrules_enable']))
{
- Exclude checks
The method main() has 108 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public function main($id, $mode)
{
global $phpbb_container;
/** @var \phpbb\language\language $lang */
- Exclude checks
The method delete_rule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
{
$is_cat = (int) ($entity->get_right_id() - $entity->get_left_id() > 1);
// Request confirmation from the user to delete the rule
confirm_box(false, $this->lang->lang('ACP_DELETE_RULE_CONFIRM', $is_cat), build_hidden_fields(array(
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method add_edit_rule_data() has 163 lines of code. Current threshold is set to 100. Avoid really long methods. 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');
- Exclude checks