ampache/ampache

View on GitHub

Showing 1,986 of 25,683 total issues

Function insert has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    public static function insert(array $results)
    {
        $check_file = Catalog::get_id_from_file($results['file'], 'song');
        if ($check_file > 0) {
            return $check_file;
Severity: Minor
Found in src/Repository/Model/Song.php - About 1 day 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 postAuth has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    public function postAuth(): ?array
    {
        $result         = [];
        $result['type'] = 'openid';
        $consumer       = Openid::get_consumer();
Severity: Minor
Found in src/Module/Authentication/Authenticator/OpenIdAuthenticator.php - About 1 day 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 62 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle(): void
    {
        $results      = array();
        $request_id   = (int)$this->requestParser->getFromRequest('id');
        $request_type = $this->requestParser->getFromRequest('type');
Severity: Minor
Found in src/Application/Api/Ajax/Handler/DefaultAjaxHandler.php - About 1 day 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 getSql has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSql(
        Search $search
    ): array {
        $search_user_id     = $search->search_user->id ?? -1;
        $sql_logic_operator = $search->logic_operator;
Severity: Minor
Found in src/Module/Playlist/Search/PodcastSearch.php - About 1 day 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 searches has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

    public static function searches($searches, $user): string
    {
        $string = "<search>\n";

        // here is where we call the object type
Severity: Minor
Found in src/Module/Api/Xml_Data.php - About 1 day 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 _parse_filename has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    private function _parse_filename($filepath): array
    {
        $origin  = $filepath;
        $results = array();
        $file    = pathinfo($filepath, PATHINFO_FILENAME);
Severity: Minor
Found in src/Module/Util/VaInfo.php - About 1 day 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 update_remote_catalog has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_remote_catalog(): int
    {
        debug_event('subsonic.catalog', 'Updating remote catalog...', 5);

        $subsonic = $this->createClient();
Severity: Minor
Found in src/Module/Catalog/Catalog_subsonic.php - About 1 day 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 getSql has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSql(
        Search $search
    ): array {
        $search_user_id     = $search->search_user->id ?? -1;
        $sql_logic_operator = $search->logic_operator;
Severity: Minor
Found in src/Module/Playlist/Search/PodcastEpisodeSearch.php - About 1 day 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 _xml2Json has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    private static function _xml2Json($xml, $input_options = array()): array
    {
        $defaults = array(
            'namespaceSeparator' => ' :', // you may want this to be something other than a colon
            'attributePrefix' => '', // to distinguish between attributes and nodes with the same name
Severity: Minor
Found in src/Module/Api/Subsonic_Api.php - About 1 day 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 databases has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    public static function databases($input): bool
    {
        $output = '';
        // Database list
        if (count($input) == 0) {
Severity: Minor
Found in src/Module/Api/Daap_Api.php - About 1 day 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 writeRating has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    public function writeRating(
        Song $song,
        User $user,
        Rating $rating
    ): void {
Severity: Minor
Found in src/Module/Song/Tag/SongTagWriter.php - About 1 day 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 createDIDL has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    public static function createDIDL($prmItems, $filterValue): DOMDocument
    {
        $xmlDoc               = new DOMDocument('1.0' /*, 'utf-8'*/);
        $xmlDoc->formatOutput = true; // Note: other players don't seem to do this
        // Create root element and add namespaces:
Severity: Minor
Found in src/Module/Api/Upnp_Api.php - About 1 day 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 get_languages has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

function get_languages(): array
{
    /* Open the locale directory */
    $handle = opendir(__DIR__ . '/../../locale');

Severity: Minor
Found in src/Config/functions.php - About 1 day 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 run has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
    {
        set_error_handler('ampache_error_handler');

        $configfile = __DIR__ . '/../../../../config/ampache.cfg.php';
Severity: Minor
Found in src/Module/Application/Installation/DefaultAction.php - About 1 day 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 58 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle(): void
    {
        $results = array();
        $action  = $this->requestParser->getFromRequest('action');

Severity: Minor
Found in src/Application/Api/Ajax/Handler/SearchAjaxHandler.php - About 1 day 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 match has 401 lines of code (exceeds 200 allowed). Consider refactoring.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Major
Found in src/Module/Util/Horde_Browser.php - About 1 day to fix

    Function catalog_folder has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function catalog_folder(array $input, User $user): bool
        {
            if (!Api::check_access('interface', 50, $user->id, self::ACTION, $input['api_format'])) {
                return false;
            }
    Severity: Minor
    Found in src/Module/Api/Method/CatalogFolderMethod.php - About 1 day 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 run has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface
        {
            $response = $this->responseFactory->createResponse();
    
            if (
    Severity: Minor
    Found in src/Module/Application/Image/ShowAction.php - About 1 day 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 57 (exceeds 5 allowed). Consider refactoring.
    Open

        public function handle(): void
        {
            if (!Core::is_session_started()) {
                session_start();
            }
    Severity: Minor
    Found in src/Application/Api/Ajax/Handler/BrowseAjaxHandler.php - About 1 day 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

    User has 61 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class User extends database_object
    {
        /** @var int Defines the internal system user-id */
        public const INTERNAL_SYSTEM_USER_ID = -1;
    
    
    Severity: Major
    Found in src/Repository/Model/User.php - About 1 day to fix
      Severity
      Category
      Status
      Source
      Language