phpbb-extensions/boardrules

View on GitHub

Showing 21 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

      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

        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

                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

                          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

                            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

                              Severity
                              Category
                              Status
                              Source
                              Language