qcminecraft/Carbon-Forum-F

View on GitHub
library/Uploader.class.php

Summary

Maintainability
F
3 days
Test Coverage

File Uploader.class.php has 336 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Created by JetBrains PhpStorm.
 * User: taoqili
 * Date: 12-7-18
Severity: Minor
Found in library/Uploader.class.php - About 4 hrs to fix

    Function upFile has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private function upFile()
        {
            $file = $this->file = $_FILES[$this->fileField];
            if (!$file) {
                $this->stateInfo = $this->getStateInfo("ERROR_FILE_NOT_FOUND");
    Severity: Minor
    Found in library/Uploader.class.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 checkIdenticalFiles has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        private function checkIdenticalFiles($tempFileName, $inputType)
        {
            if ($this->DB) {
                if ($inputType == 'string') {
                    $this->fileMD5  = md5($tempFileName);
    Severity: Minor
    Found in library/Uploader.class.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 saveRemote has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function saveRemote()
        {
            $imgUrl = htmlspecialchars($this->fileField);
            $imgUrl = str_replace("&amp;", "&", $imgUrl);
            
    Severity: Major
    Found in library/Uploader.class.php - About 2 hrs to fix

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

          private function saveRemote()
          {
              $imgUrl = htmlspecialchars($this->fileField);
              $imgUrl = str_replace("&amp;", "&", $imgUrl);
              
      Severity: Minor
      Found in library/Uploader.class.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 upFile has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function upFile()
          {
              $file = $this->file = $_FILES[$this->fileField];
              if (!$file) {
                  $this->stateInfo = $this->getStateInfo("ERROR_FILE_NOT_FOUND");
      Severity: Minor
      Found in library/Uploader.class.php - About 1 hr to fix

        Method checkIdenticalFiles has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function checkIdenticalFiles($tempFileName, $inputType)
            {
                if ($this->DB) {
                    if ($inputType == 'string') {
                        $this->fileMD5  = md5($tempFileName);
        Severity: Minor
        Found in library/Uploader.class.php - About 1 hr to fix

          Method upBase64 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function upBase64()
              {
                  $base64Data = $_POST[$this->fileField];
                  $img        = base64_decode($base64Data);
                  
          Severity: Minor
          Found in library/Uploader.class.php - About 1 hr to fix

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

                private function upBase64()
                {
                    $base64Data = $_POST[$this->fileField];
                    $img        = base64_decode($base64Data);
                    
            Severity: Minor
            Found in library/Uploader.class.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

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

                public function __construct($fileField, $config, $type, $CurUserName, $DB = '')
            Severity: Minor
            Found in library/Uploader.class.php - About 35 mins to fix

              Avoid too many return statements within this method.
              Open

                          return;
              Severity: Major
              Found in library/Uploader.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return;
                Severity: Major
                Found in library/Uploader.class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return;
                  Severity: Major
                  Found in library/Uploader.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return;
                    Severity: Major
                    Found in library/Uploader.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return;
                      Severity: Major
                      Found in library/Uploader.class.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return;
                        Severity: Major
                        Found in library/Uploader.class.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return;
                          Severity: Major
                          Found in library/Uploader.class.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return;
                            Severity: Major
                            Found in library/Uploader.class.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return;
                              Severity: Major
                              Found in library/Uploader.class.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return;
                                Severity: Major
                                Found in library/Uploader.class.php - About 30 mins to fix

                                  There are no issues that match your filters.

                                  Category
                                  Status