efureev/laravel-files

View on GitHub

Showing 9 of 14 total issues

Method up has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function up(): void
    {
        Schema::create(config('files.table.name'), function (Blueprint $table): void {
            $typeId = config('files.table.id');

Severity: Minor
Found in database/migrations/2018_12_24_1339_create_files_table.php - About 1 hr to fix

    Function beforeUploadFile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function beforeUploadFile(UploadedFile $file): UploadedFile
        {
            if (!$this->beforeUploadActions || !is_array($this->beforeUploadActions)) {
                return $file;
            }
    Severity: Minor
    Found in src/Services/UploadService.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

    Function afterUploadFile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        private function afterUploadFile(BaseFile $baseFile)
        {
            if (!$this->afterUploadActions || !is_array($this->afterUploadActions)) {
                return $baseFile;
            }
    Severity: Minor
    Found in src/Services/UploadService.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

    Function mimeIs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function mimeIs(string $mimeExist, string $mimeAsk): bool
        {
            if (empty($mimeExist) || empty($mimeAsk)) {
                return false;
            }
    Severity: Minor
    Found in src/Support/Types.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

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

        public function handle($model, ... $options)
        {
            if ($this->width !== null && $this->height !== null) {
                if ($this->bestFit) {
                    $model->getImageProcessor()->resizeToBestFit($this->width, $this->height, ...$options);
    Severity: Minor
    Found in src/Entities/Modificators/ResizeModificator.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 up has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function up(): void
        {
            Schema::create(config('files.table.name'), function (Blueprint $table): void {
                $typeId = config('files.table.id');
    
    
    Severity: Minor
    Found in database/migrations/2018_12_24_1339_create_files_table.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

    Avoid too many return statements within this method.
    Open

                return true;
    Severity: Major
    Found in src/Support/Types.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return File::class;
      Severity: Major
      Found in src/Traits/FileTypes.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return $formatExist === $formatAsk;
        Severity: Major
        Found in src/Support/Types.php - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language