thomas-claireau/PHP-P5-Openclassrooms

View on GitHub

Showing 26 of 26 total issues

Function uploadImg has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

    public function uploadImg($type = null, $id = null, $action = null)
    {
        $accepted_origins = array("http://localhost:3000", "http://82.64.201.160", "http://recette.thomas-claireau.fr", "https://recette.thomas-claireau.fr");
        $type = $type == null ? $this->inputGet('type') : $type;

Severity: Minor
Found in src/Controller/MainController.php - About 5 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

Function exports has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (options) => {
  const { dev } = options;
  const hmr = HMR.getClient();

  return {
Severity: Major
Found in public/_webpack/webpack.config.js - About 4 hrs to fix

    Method uploadImg has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function uploadImg($type = null, $id = null, $action = null)
        {
            $accepted_origins = array("http://localhost:3000", "http://82.64.201.160", "http://recette.thomas-claireau.fr", "https://recette.thomas-claireau.fr");
            $type = $type == null ? $this->inputGet('type') : $type;
    
    
    Severity: Major
    Found in src/Controller/MainController.php - About 2 hrs to fix

      Function checkAllInput has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function checkAllInput($context)
          {
              $post = MainController::getData();
      
              if ($context == 'contact') {
      Severity: Minor
      Found in src/Controller/Functions/MainFunctions.php - About 2 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

      Function updateAccount has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function updateAccount()
          {
              // session_start();
      
              $outputData = $this->data;
      Severity: Minor
      Found in src/Controller/AuthController.php - About 2 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

      Method sendEmail has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sendEmail()
          {
              require_once 'setup/configMail.php';
              $serveurName = $configMail['smtp'];
              $port = $configMail['port'];
      Severity: Major
      Found in src/Controller/MailController.php - About 2 hrs to fix

        Function defaultMethod has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function defaultMethod()
            {
                $action = $this->inputGet('action');
                $type = $this->inputGet('type');
        
        
        Severity: Minor
        Found in src/Controller/AdminController.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 addAccount has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function addAccount()
            {
                require_once 'setup/configMail.php';
                $serveurName = $configMail['smtp'];
                $port = $configMail['port'];
        Severity: Minor
        Found in src/Controller/AuthController.php - About 1 hr to fix

          Method sendForgotPassword has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function sendForgotPassword()
              {
                  require_once 'setup/configMail.php';
                  $serveurName = $configMail['smtp'];
                  $port = $configMail['port'];
          Severity: Minor
          Found in src/Controller/AuthController.php - About 1 hr to fix

            Method defaultMethod has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function defaultMethod()
                {
                    $action = $this->inputGet('action');
                    $type = $this->inputGet('type');
            
            
            Severity: Minor
            Found in src/Controller/AdminController.php - About 1 hr to fix

              Function inputPost has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function inputPost($key = false, $isArray = true)
                  {
                      if (!$isArray && $key) {
                          $post = filter_input(INPUT_POST, $key);
                          switch ($key) {
              Severity: Minor
              Found in src/Controller/Functions/MainFunctions.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 checkAllInput has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function checkAllInput($context)
                  {
                      $post = MainController::getData();
              
                      if ($context == 'contact') {
              Severity: Minor
              Found in src/Controller/Functions/MainFunctions.php - About 1 hr to fix

                Function getPost has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getPost(array $key = null)
                    {
                        if (isset($key) && !empty($key)) {
                            $posts = ModelFactory::getModel('Post')->listData($key[key($key)], key($key));
                
                
                Severity: Minor
                Found in src/Controller/AdminController.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 inputPost has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function inputPost($key = false, $isArray = true)
                    {
                        if (!$isArray && $key) {
                            $post = filter_input(INPUT_POST, $key);
                            switch ($key) {
                Severity: Minor
                Found in src/Controller/Functions/MainFunctions.php - About 1 hr to fix

                  Method updateAccount has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function updateAccount()
                      {
                          // session_start();
                  
                          $outputData = $this->data;
                  Severity: Minor
                  Found in src/Controller/AuthController.php - About 1 hr to fix

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                                    } else {
                                        trigerForm.textContent = 'Mettre à jour';
                                        trigerForm.classList.remove('rougeFonce');
                                        trigerForm.classList.add('vertFonce');
                                        inputPass.value = 'password';
                    Severity: Major
                    Found in public/src/js/pages/admin/account.js and 1 other location - About 1 hr to fix
                    public/src/js/pages/admin/account.js on lines 14..19

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 55.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                                    if (form.classList.contains('disabled')) {
                                        trigerForm.textContent = 'Annuler';
                                        trigerForm.classList.remove('vertFonce');
                                        trigerForm.classList.add('rougeFonce');
                                        inputPass.value = '';
                    Severity: Major
                    Found in public/src/js/pages/admin/account.js and 1 other location - About 1 hr to fix
                    public/src/js/pages/admin/account.js on lines 19..24

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 55.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Function getServerIP has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private static function getServerIP()
                        {
                            $adresse = '';
                            $server = filter_input_array(INPUT_SERVER);
                    
                    
                    Severity: Minor
                    Found in src/Controller/Functions/MainFunctions.php - About 45 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 exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = (options) => {
                      const { dev } = options;
                      const hmr = HMR.getClient();
                    
                      return {
                    Severity: Minor
                    Found in public/_webpack/webpack.config.js - About 45 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 listData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function listData(string $value = null, string $key = null, array $params = null)
                        {
                            if (isset($key)) {
                                $query = 'SELECT * FROM ' . $this->table . ' WHERE ' . $key . ' = ?';
                    
                    
                    Severity: Minor
                    Found in src/Model/MainModel.php - About 45 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