phpbb-extensions/boardrules

View on GitHub

Showing 86 of 86 total issues

Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\language\language $lang, \phpbb\boardrules\operators\rule $rule_operator, \phpbb\template\template $template, \phpbb\user $user, $root_path, $php_ext)
Severity: Major
Found in controller/main_controller.php - About 1 hr to fix

    Function import has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function import($data)
        {
            // Clear out any saved data
            $this->data = array();
    
    
    Severity: Minor
    Found in entity/rule.php - About 55 mins to fix

    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 set_anchor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function set_anchor($anchor)
        {
            // Enforce a string
            $anchor = (string) $anchor;
    
    
    Severity: Minor
    Found in entity/rule.php - About 55 mins to fix

    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 admin_controller has a coupling between objects value of 16. Consider to reduce the number of dependencies under 13.
    Open

    class admin_controller implements admin_interface
    {
        /** @var \phpbb\config\config */
        protected $config;
    
    
    Severity: Minor
    Found in controller/admin_controller.php by phpmd

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct(\phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\language\language $lang, \phpbb\template\template $template, $php_ext)
    Severity: Minor
    Found in event/listener.php - About 35 mins to fix

      Function build_parent_select_menu has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function build_parent_select_menu($entity, $parent_id = 0)
          {
              // Prepare rule pull-down field
              $rule_menu_items = $this->rule_operator->get_rules($entity->get_language());
      
      
      Severity: Minor
      Found in controller/admin_controller.php - About 35 mins to fix

      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

      Missing class import via use statement (line '129', column '15').
      Open

                      throw new \phpbb\boardrules\exception\invalid_argument(array($field, 'FIELD_MISSING'));
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '185', column '14').
      Open

                  throw new \phpbb\boardrules\exception\out_of_bounds('rule_id');
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '75', column '14').
      Open

                  throw new \RuntimeException('The column ‘rule_language’ could not be renamed.');

      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 '279', column '14').
      Open

                  throw new \phpbb\boardrules\exception\unexpected_value(array('title', 'TOO_LONG'));
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '492', column '14').
      Open

                  throw new \phpbb\boardrules\exception\unexpected_value(array('anchor', 'TOO_LONG'));
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '163', column '15').
      Open

                      throw new \phpbb\boardrules\exception\out_of_bounds($field);
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '174', column '14').
      Open

                  throw new \phpbb\boardrules\exception\out_of_bounds($field);
      Severity: Minor
      Found in operators/rule.php by phpmd

      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 '91', column '17').
      Open

              $helper = new \phpbb\boardrules\migrations\helper($this->db, $this->table_prefix);

      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 '81', column '14').
      Open

                  throw new \phpbb\boardrules\exception\out_of_bounds('rule_id');
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '486', column '14').
      Open

                  throw new \phpbb\boardrules\exception\unexpected_value(array('anchor', 'ILLEGAL_CHARACTERS'));
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '511', column '15').
      Open

                      throw new \phpbb\boardrules\exception\unexpected_value(array('anchor', 'NOT_UNIQUE'));
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 $reparse_message, which is a certain sign of a Single Responsibility Principle violation.
      Open

          protected function set_message_option($option_value, $negate = false, $reparse_message = true)
      Severity: Minor
      Found in entity/rule.php by phpmd

      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 '121', column '14').
      Open

                  throw new \phpbb\boardrules\exception\out_of_bounds('rule_id');
      Severity: Minor
      Found in operators/rule.php by phpmd

      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 '14').
      Open

                  throw new \RuntimeException('The column ‘rule_language’ could not be created.');

      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

      Severity
      Category
      Status
      Source
      Language