ampache/ampache

View on GitHub
src/Module/Util/Upload.php

Summary

Maintainability
D
1 day
Test Coverage

process accesses the super-global variable $_FILES.
Open

    public static function process(): bool
    {
        header('Content-Type: application/json');
        ob_start();
        define('CLI', true);
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

process accesses the super-global variable $_FILES.
Open

    public static function process(): bool
    {
        header('Content-Type: application/json');
        ob_start();
        define('CLI', true);
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

check accesses the super-global variable $_FILES.
Open

    public static function check(int $catalog_id): ?Catalog
    {
        if ($catalog_id === 0) {
            return null;
        }
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

process accesses the super-global variable $_POST.
Open

    public static function process(): bool
    {
        header('Content-Type: application/json');
        ob_start();
        define('CLI', true);
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

check accesses the super-global variable $_FILES.
Open

    public static function check(int $catalog_id): ?Catalog
    {
        if ($catalog_id === 0) {
            return null;
        }
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

check accesses the super-global variable $_FILES.
Open

    public static function check(int $catalog_id): ?Catalog
    {
        if ($catalog_id === 0) {
            return null;
        }
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function process has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    public static function process(): bool
    {
        header('Content-Type: application/json');
        ob_start();
        define('CLI', true);
Severity: Minor
Found in src/Module/Util/Upload.php - About 6 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 Upload has an overall complexity of 56 which is very high. The configured complexity threshold is 50.
Open

class Upload
{
    /**
     * process
     */
Severity: Minor
Found in src/Module/Util/Upload.php by phpmd

Function get_root has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function get_root($catalog = null, $username = null): string
    {
        if ($catalog == null) {
            $catalog_id = AmpConfig::get('upload_catalog');
            if ($catalog_id > 0) {
Severity: Minor
Found in src/Module/Util/Upload.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 check has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function check(int $catalog_id): ?Catalog
    {
        if ($catalog_id === 0) {
            return null;
        }
Severity: Minor
Found in src/Module/Util/Upload.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

Avoid too many return statements within this method.
Open

                    return self::rerror($targetfile);
Severity: Major
Found in src/Module/Util/Upload.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return null;
    Severity: Major
    Found in src/Module/Util/Upload.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return self::rerror();
      Severity: Major
      Found in src/Module/Util/Upload.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return true;
        Severity: Major
        Found in src/Module/Util/Upload.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                                  return self::rerror($targetfile);
          Severity: Major
          Found in src/Module/Util/Upload.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                    return self::rerror($targetfile);
            Severity: Major
            Found in src/Module/Util/Upload.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                      return self::rerror($targetfile);
              Severity: Major
              Found in src/Module/Util/Upload.php - About 30 mins to fix

                The method process() has an NPath complexity of 3209. The configured NPath complexity threshold is 200.
                Open

                    public static function process(): bool
                    {
                        header('Content-Type: application/json');
                        ob_start();
                        define('CLI', true);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                NPathComplexity

                Since: 0.1

                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                Example

                class Foo {
                    function bar() {
                        // lots of complicated code
                    }
                }

                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                The method process() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
                Open

                    public static function process(): bool
                    {
                        header('Content-Type: application/json');
                        ob_start();
                        define('CLI', true);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CyclomaticComplexity

                Since: 0.1

                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                Example

                // Cyclomatic Complexity = 11
                class Foo {
                1   public function example() {
                2       if ($a == $b) {
                3           if ($a1 == $b1) {
                                fiddle();
                4           } elseif ($a2 == $b2) {
                                fiddle();
                            } else {
                                fiddle();
                            }
                5       } elseif ($c == $d) {
                6           while ($c == $d) {
                                fiddle();
                            }
                7        } elseif ($e == $f) {
                8           for ($n = 0; $n < $h; $n++) {
                                fiddle();
                            }
                        } else {
                            switch ($z) {
                9               case 1:
                                    fiddle();
                                    break;
                10              case 2:
                                    fiddle();
                                    break;
                11              case 3:
                                    fiddle();
                                    break;
                                default:
                                    fiddle();
                                    break;
                            }
                        }
                    }
                }

                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                Reduce the number of returns of this function 10, down to the maximum allowed 3.
                Open

                    public static function process(): bool
                Severity: Major
                Found in src/Module/Util/Upload.php by sonar-php

                Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                Noncompliant Code Example

                With the default threshold of 3:

                function myFunction(){ // Noncompliant as there are 4 return statements
                  if (condition1) {
                    return true;
                  } else {
                    if (condition2) {
                      return false;
                    } else {
                      return true;
                    }
                  }
                  return false;
                }
                

                Reduce the number of returns of this function 5, down to the maximum allowed 3.
                Open

                    public static function check(int $catalog_id): ?Catalog
                Severity: Major
                Found in src/Module/Util/Upload.php by sonar-php

                Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                Noncompliant Code Example

                With the default threshold of 3:

                function myFunction(){ // Noncompliant as there are 4 return statements
                  if (condition1) {
                    return true;
                  } else {
                    if (condition2) {
                      return false;
                    } else {
                      return true;
                    }
                  }
                  return false;
                }
                

                Reduce the number of returns of this function 4, down to the maximum allowed 3.
                Open

                    public static function check_artist($artist_name, $user_id): ?int
                Severity: Major
                Found in src/Module/Util/Upload.php by sonar-php

                Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

                Noncompliant Code Example

                With the default threshold of 3:

                function myFunction(){ // Noncompliant as there are 4 return statements
                  if (condition1) {
                    return true;
                  } else {
                    if (condition2) {
                      return false;
                    } else {
                      return true;
                    }
                  }
                  return false;
                }
                

                Refactor this function to reduce its Cognitive Complexity from 45 to the 15 allowed.
                Open

                    public static function process(): bool
                Severity: Critical
                Found in src/Module/Util/Upload.php by sonar-php

                Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

                See

                The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            debug_event(self::class, 'No catalog target upload configured.', 1);
                        }
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method check uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                        } else {
                            debug_event(self::class, 'File upload error (check filesize limits).', 2);
                        }
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                Open

                            } else {
                                debug_event(self::class, 'Cannot copy the file to target directory. Please check write access.', 1);
                            }
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                ElseExpression

                Since: 1.4.0

                An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                Example

                class Foo
                {
                    public function bar($flag)
                    {
                        if ($flag) {
                            // one branch
                        } else {
                            // another branch
                        }
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#elseexpression

                Merge this if statement with the enclosing one.
                Open

                                if (AmpConfig::get('upload_subdir')) {
                Severity: Major
                Found in src/Module/Util/Upload.php by sonar-php

                Merging collapsible if statements increases the code's readability.

                Noncompliant Code Example

                if (condition1) {
                  if (condition2) {
                    ...
                  }
                }
                

                Compliant Solution

                if (condition1 && condition2) {
                  ...
                }
                

                Define a constant instead of duplicating this literal "artist_id" 3 times.
                Open

                                    $options['artist_id'] = (int)Core::get_request('artist');
                Severity: Critical
                Found in src/Module/Util/Upload.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define a constant instead of duplicating this literal "license" 3 times.
                Open

                                if (isset($_POST['license'])) {
                Severity: Critical
                Found in src/Module/Util/Upload.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Merge this if statement with the enclosing one.
                Open

                            if (unlink($file) === false) {
                Severity: Major
                Found in src/Module/Util/Upload.php by sonar-php

                Merging collapsible if statements increases the code's readability.

                Noncompliant Code Example

                if (condition1) {
                  if (condition2) {
                    ...
                  }
                }
                

                Compliant Solution

                if (condition1 && condition2) {
                  ...
                }
                

                Define a constant instead of duplicating this literal "user_upload" 3 times.
                Open

                                $options['user_upload'] = Core::get_global('user')->id;
                Severity: Critical
                Found in src/Module/Util/Upload.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Define and throw a dedicated exception instead of using a generic one.
                Open

                                throw new RuntimeException('The file handle ' . $file . ' could not be unlinked');
                Severity: Major
                Found in src/Module/Util/Upload.php by sonar-php

                If you throw a general exception type, such as ErrorException, RuntimeException, or Exception in a library or framework, it forces consumers to catch all exceptions, including unknown exceptions that they do not know how to handle.

                Instead, either throw a subtype that already exists in the Standard PHP Library, or create your own type that derives from Exception.

                Noncompliant Code Example

                throw new Exception();  // Noncompliant
                

                Compliant Solution

                throw new InvalidArgumentException();
                // or
                throw new UnexpectedValueException();
                

                See

                Define a constant instead of duplicating this literal "upload_catalog" 3 times.
                Open

                        $catalog_id = (int)AmpConfig::get('upload_catalog', 0);
                Severity: Critical
                Found in src/Module/Util/Upload.php by sonar-php

                Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

                On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

                Noncompliant Code Example

                With the default threshold of 3:

                function run() {
                  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
                  execute('action1');
                  release('action1');
                }
                

                Compliant Solution

                ACTION_1 = 'action1';
                
                function run() {
                  prepare(ACTION_1);
                  execute(ACTION_1);
                  release(ACTION_1);
                }
                

                Exceptions

                To prevent generating some false-positives, literals having less than 5 characters are excluded.

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                        debug_event(self::class, 'Target user directory `' . $rootdir . "` doesn't exist. Creating it...", 5);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method add_file from undeclared class \Ampache\Repository\Model\Catalog
                Open

                                if (!$catalog->add_file($targetfile, $options)) {
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to method __construct from undeclared class \Ampache\Repository\Model\Artist
                Open

                            $artist = new Artist($artist_id);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\System\Core::get_request() defined at /code/src/Module/System/Core.php:61
                Open

                                if (Core::get_request('album_name') !== '') {
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                            debug_event(self::class, 'File extension `' . $extension . '` not allowed.', 2);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                debug_event(self::class, 'An artist with the name "' . $artist_name . '" already exists, uploaded song skipped.', 3);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method check from undeclared class \Ampache\Repository\Model\Artist
                Open

                            $artist_id = (int)Artist::check($artist_name);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Parameter $catalog has undeclared type \Ampache\Repository\Model\Catalog
                Open

                    public static function get_root($catalog = null, $username = null): string
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method create_from_id from undeclared class \Ampache\Repository\Model\Catalog
                Open

                                $catalog = Catalog::create_from_id($catalog_id);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to method get_path from undeclared class \Ampache\Repository\Model\Catalog
                Open

                            $rootdir = realpath($catalog->get_path());
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\System\Core::get_request() defined at /code/src/Module/System/Core.php:61
                Open

                                if (Core::get_request('artist_name') !== '') {
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\System\Core::get_request() defined at /code/src/Module/System/Core.php:61
                Open

                                    $album_id = self::check_album(Core::get_request('album_name'), ($options['artist_id'] ?? null));
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                        debug_event(self::class, "Album owner doesn't match the current user.", 3);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                debug_event(self::class, 'Artist information required, uploaded song skipped.', 3);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                            debug_event(self::class, 'Something wrong with final upload path.', 1);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method get_user_owner from undeclared class \Ampache\Repository\Model\Album
                Open

                                    if ($album->get_user_owner() != $options['user_upload']) {
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                    debug_event(self::class, 'Failed adding uploaded file to catalog.', 1);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method update_table_counts from undeclared class \Ampache\Repository\Model\Album
                Open

                                Album::update_table_counts();
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                debug_event(self::class, 'Cannot copy the file to target directory. Please check write access.', 1);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                        debug_event(self::class, 'check_artist: looking for ' . $artist_name, 5);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Reference to instance property id from undeclared class \Ampache\Repository\Model\Catalog
                Open

                        if ($catalog !== null && $catalog->id) {
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                            debug_event(self::class, 'Uploading to catalog ID ' . $catalog_id, 4);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                        debug_event(self::class, "Artist owner doesn't match the current user.", 3);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method update_table_counts from undeclared class \Ampache\Repository\Model\Artist
                Open

                                Artist::update_table_counts();
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to method create_from_id from undeclared class \Ampache\Repository\Model\Catalog
                Open

                            $catalog = Catalog::create_from_id($catalog_id);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to method __construct from undeclared class \Ampache\Repository\Model\Album
                Open

                                    $album = new Album($album_id);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                            debug_event(self::class, 'File upload error (check filesize limits).', 2);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method check from undeclared class \Ampache\Repository\Model\Album
                Open

                            $album_id = Album::check(AmpConfig::get('upload_catalog'), $album_name, 0, null, null, $artist_id);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                        debug_event(self::class, 'Target Directory `' . $targetdir, 4);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Parameter $user has undeclared type \Ampache\Repository\Model\User
                Open

                    public static function can_upload($user = null): bool
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Return type of check() is undeclared type ?\Ampache\Repository\Model\Catalog
                Open

                    public static function check(int $catalog_id): ?Catalog
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method check from undeclared class \Ampache\Repository\Model\Artist
                Open

                            if (Artist::check($artist_name, '', true) !== null) {
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                        debug_event(self::class, 'Target File `' . $targetfile, 4);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\Authorization\Access::check() defined at /code/src/Module/Authorization/Access.php:154
                Open

                        $can_upload = Access::check('interface', AmpConfig::get('upload_access_level', 25));
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                debug_event(self::class, 'Album information required, uploaded song skipped.', 3);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\System\Core::get_request() defined at /code/src/Module/System/Core.php:61
                Open

                                if (Core::get_request('artist') !== '') {
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\System\Core::get_request() defined at /code/src/Module/System/Core.php:61
                Open

                                    $options['artist_id'] = (int)Core::get_request('artist');
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Reference to instance property access from undeclared class \Ampache\Repository\Model\User
                Open

                        $user_access = $user->access ?? -1;
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method update_artist_user from undeclared class \Ampache\Repository\Model\Artist
                Open

                            $artist->update_artist_user($user_id); // take ownership of the new artist
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to method __construct from undeclared class \Ampache\Repository\Model\Artist
                Open

                                    $artist = new Artist($artist_id);
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                        debug_event(self::class, 'check_album: looking for ' . $album_name, 5);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                debug_event(self::class, 'File uploaded to `' . $targetfile . '`.', 5);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \Ampache\Module\System\Core::get_request() defined at /code/src/Module/System/Core.php:61
                Open

                                    $artist_id = self::check_artist(Core::get_request('artist_name'), Core::get_global('user')->id);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to method get_user_owner from undeclared class \Ampache\Repository\Model\Artist
                Open

                                    if ($artist->get_user_owner() != $options['user_upload']) {
                Severity: Critical
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                            debug_event(self::class, 'No catalog target upload configured.', 1);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                            debug_event(self::class, 'File `' . $targetfile . '` already exists.', 3);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                Call to deprecated function \debug_event() defined at /code/src/Config/functions.php:651
                Open

                                debug_event(self::class, 'File `' . $targetfile . '` already exists.', 1);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phan

                The parameter $user_id is not named in camelCase.
                Open

                    public static function check_artist($artist_name, $user_id): ?int
                    {
                        debug_event(self::class, 'check_artist: looking for ' . $artist_name, 5);
                        if ($artist_name !== '') {
                            if (Artist::check($artist_name, '', true) !== null) {
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $artist_id is not named in camelCase.
                Open

                    public static function check_album($album_name, $artist_id): ?int
                    {
                        debug_event(self::class, 'check_album: looking for ' . $album_name, 5);
                        if ($album_name !== '') {
                            $album_id = Album::check(AmpConfig::get('upload_catalog'), $album_name, 0, null, null, $artist_id);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $catalog_dir is not named in camelCase.
                Open

                    public static function check_target_dir($catalog_dir): ?string
                    {
                        $targetdir = $catalog_dir;
                        $folder    = (Core::get_post('folder') == '..') ? '' : Core::get_post('folder');
                
                
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $album_name is not named in camelCase.
                Open

                    public static function check_album($album_name, $artist_id): ?int
                    {
                        debug_event(self::class, 'check_album: looking for ' . $album_name, 5);
                        if ($album_name !== '') {
                            $album_id = Album::check(AmpConfig::get('upload_catalog'), $album_name, 0, null, null, $artist_id);
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $catalog_id is not named in camelCase.
                Open

                    public static function check(int $catalog_id): ?Catalog
                    {
                        if ($catalog_id === 0) {
                            return null;
                        }
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                The parameter $artist_name is not named in camelCase.
                Open

                    public static function check_artist($artist_name, $user_id): ?int
                    {
                        debug_event(self::class, 'check_artist: looking for ' . $artist_name, 5);
                        if ($artist_name !== '') {
                            if (Artist::check($artist_name, '', true) !== null) {
                Severity: Minor
                Found in src/Module/Util/Upload.php by phpmd

                CamelCaseParameterName

                Since: 0.2

                It is considered best practice to use the camelCase notation to name parameters.

                Example

                class ClassName {
                    public function doSomething($user_name) {
                    }
                }

                Source

                There are no issues that match your filters.

                Category
                Status