ampache/ampache

View on GitHub
public/templates/show_top_tracks.inc.php

Summary

Maintainability
F
4 days
Test Coverage

Variable $hide_columns is undeclared
Open

$hide_year    = in_array('cel_year', $hide_columns);

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

    $libitem = new Song($song_id);
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Expected an object instance when accessing an instance property, but saw an expression with type string
Open

<table id="top_tracks_<?php echo $artist->id; ?>" class="tabledata striped-rows">
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Call to method build_cache from undeclared class \Ampache\Repository\Model\Userflag
Open

                Userflag::build_cache('song', $object_ids);
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Call to method isNew from undeclared class \Ampache\Repository\Model\Song
Open

    if ($libitem->isNew()) {
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Variable $hide_columns is undeclared
Open

$hide_album   = in_array('cel_album', $hide_columns);

Call to method build_cache from undeclared class \Ampache\Repository\Model\Rating
Open

                Rating::build_cache('song', $object_ids);
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

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

            <tr id="song_<?php echo $libitem->id; ?>">

Variable $hide_columns is undeclared
Open

$hide_drag    = in_array('cel_drag', $hide_columns);

Call to method is_registered from undeclared class \Ampache\Repository\Model\User
Open

$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Call to method format from undeclared class \Ampache\Repository\Model\Song
Open

    $libitem->format(); ?>
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Reference to instance property enabled from undeclared class \Ampache\Repository\Model\Song
Open

        if ($libitem->enabled || Access::check('interface', 50)) {

Call to method is_registered from undeclared class \Ampache\Repository\Model\User
Open

                ->setContext('USER_IS_REGISTERED', User::is_registered())
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Possibly zero references to use statement for classlike/namespace Artist (\Ampache\Repository\Model\Artist)
Open

use Ampache\Repository\Model\Artist;

Call to method is_registered from undeclared class \Ampache\Repository\Model\User
Open

                ->setContext('USING_RATINGS', User::is_registered() && (AmpConfig::get('ratings')))
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

Variable $hide_columns is undeclared
Open

$hide_artist  = in_array('cel_artist', $hide_columns);

Expected an object instance when accessing an instance property, but saw an expression with type string
Open

    var indexes = $("#top_tracks_<?php echo $artist->id; ?> .cel_play_content").each(function() {
Severity: Critical
Found in public/templates/show_top_tracks.inc.php by phan

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

        if ($libitem->enabled || Access::check('interface', 50)) {

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

$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));

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.

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

<?php

declare(strict_types=0);

/**
Severity: Major
Found in public/templates/show_top_tracks.inc.php and 1 other location - About 4 days to fix
public/templates/show_similar_songs.inc.php on lines 1..142

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 745.

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

Line indented incorrectly; expected 24 spaces, found 8
Open

        if ($libitem->enabled || Access::check('interface', 50)) {

Closing brace indented incorrectly; expected 8 spaces, found 12
Open

            <?php } ?>

Line indented incorrectly; expected at least 8 spaces, found 0
Open

$talFactory = $dic->get(TalFactoryInterface::class);

Line indented incorrectly; expected 8 spaces, found 0
Open

foreach ($object_ids as $song_id) {

Line indented incorrectly; expected at least 12 spaces, found 4
Open

    $libitem->format(); ?>

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_SHOW_TRACK', !empty($argument))

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_SHOW_LICENSE', $show_license)

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->render();

Line indented incorrectly; expected 12 spaces, found 4
Open

    }

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('USER_IS_REGISTERED', User::is_registered())

Line indented incorrectly; expected at least 12 spaces, found 4
Open

    $libitem = new Song($song_id);

Line indented incorrectly; expected 8 spaces, found 0
Open

} ?>

Line indented incorrectly; expected at least 8 spaces, found 0
Open

$guiFactory = $dic->get(GuiFactoryInterface::class);

Line indented incorrectly; expected at least 8 spaces, found 0
Open

$gatekeeper = $dic->get(GatekeeperFactoryInterface::class)->createGuiGatekeeper();

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_HIDE_GENRE', $hide_genres)

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_TABLE_VIEW', $is_table)

Closing brace indented incorrectly; expected 8 spaces, found 12
Open

            <?php } ?>

Line indented incorrectly; expected at least 28 spaces, found 12
Open

            $content = $talFactory->createTalView()

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('SONG', $guiFactory->createSongViewAdapter($gatekeeper, $libitem))

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('USING_RATINGS', User::is_registered() && (AmpConfig::get('ratings')))

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('ARGUMENT_PARAM', '')

Line indented incorrectly; expected 0 spaces, found 8
Open

        } ?>

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_HIDE_ARTIST', $hide_artist)

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_HIDE_DRAG', (empty($argument) || $hide_drag))

Line indented incorrectly; expected 24 spaces, found 8
Open

        } ?>

Line indented incorrectly; expected 0 spaces, found 12
Open

            }

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_ALBUM_GROUP', $is_group)

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_HIDE_YEAR', $hide_year)

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setTemplate('song_row.xhtml')

Line indented incorrectly; expected 12 spaces, found 4
Open

    if ($libitem->isNew()) {

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('CONFIG', $guiFactory->createConfigViewAdapter())

Line indented incorrectly; expected at least 28 spaces, found 16
Open

                ->setContext('IS_HIDE_ALBUM', $hide_album)

Line indented incorrectly; expected at least 16 spaces, found 8
Open

        continue;

Line indented incorrectly; expected at least 28 spaces, found 12
Open

            echo $content;

There are no issues that match your filters.

Category
Status