phpbb-extensions/boardrules

View on GitHub

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.
*
Severity: Minor
Found in controller/admin_controller.php - About 5 hrs to fix

    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');
    Severity: Major
    Found in controller/admin_controller.php - About 4 hrs to fix

      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');
      Severity: Minor
      Found in controller/admin_controller.php - About 4 hrs 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 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
          *
      Severity: Minor
      Found in entity/rule.php by phpmd

      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
          *
      Severity: Minor
      Found in entity/rule.php by phpmd

      rule has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class rule implements rule_interface
      {
          /**
          * Data for this entity
          *
      Severity: Minor
      Found in entity/rule.php - About 3 hrs to fix

        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;
        
        
        Severity: Minor
        Found in controller/admin_controller.php by phpmd

        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']))
                {
        Severity: Major
        Found in controller/main_controller.php - About 2 hrs to fix

          File rule.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
          *
          * Board Rules extension for the phpBB Forum Software package.
          *
          Severity: Minor
          Found in entity/rule.php - About 2 hrs to fix

            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 */
            Severity: Major
            Found in acp/boardrules_module.php - About 2 hrs to fix

              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']))
                      {
              Severity: Minor
              Found in controller/main_controller.php - About 1 hr 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

              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();
              
              
              Severity: Minor
              Found in entity/rule.php - About 1 hr to fix

                Avoid excessively long variable names like $message_parse_options. Keep variable name length under 20.
                Open

                        $message_parse_options = array(
                Severity: Minor
                Found in controller/admin_controller.php by phpmd

                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', '');
                Severity: Minor
                Found in controller/admin_controller.php by phpmd

                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)
                Severity: Major
                Found in controller/admin_controller.php - About 1 hr to fix

                  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 */
                  Severity: Minor
                  Found in acp/boardrules_module.php - About 1 hr 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

                  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);
                  
                  
                  Severity: Minor
                  Found in controller/admin_controller.php - About 1 hr to fix

                    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');
                    
                    
                    Severity: Minor
                    Found in controller/admin_controller.php - About 1 hr to fix

                      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');
                      
                      
                      Severity: Minor
                      Found in migrations/v10x/m7_sample_rule_data.php - About 1 hr to fix

                        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;
                        
                        
                        Severity: Minor
                        Found in entity/rule.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language