Showing 120 of 336 total issues
Function useDraggable
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const useDraggable = (type: DraggableType) => {
const startDragging = (event: DragEvent, dragged: Draggable) => {
if (!event.dataTransfer) {
return
}
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public ?string $title,
public ?string $albumName,
public ?string $artistName,
public ?string $albumArtistName,
public ?int $track,
Function useUpload
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const useUpload = () => {
const { isAdmin } = useAuthorization()
const { toastSuccess, toastWarning } = useMessageToaster()
const { go, isCurrentScreen } = useRouter()
Function test
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('renders without a current song', () => expect(this.renderComponent()[0].html()).toMatchSnapshot())
it('sets the active tab to the preference', async () => {
preferenceStore.activeExtraPanelTab = 'YouTube'
Function constructor
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor (container: HTMLElement, fov = 36) {
this.container = container
this.fov = fov
this.camera = new THREE.PerspectiveCamera(
Function test
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('initializes the store', async () => {
const songSyncMock = this.mock(songStore, 'syncWithVault')
const albumSyncMock = this.mock(albumStore, 'syncWithVault')
const artistSyncMock = this.mock(artistStore, 'syncWithVault')
Function init
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const init = (container: HTMLElement) => {
const sceneInit = new SceneInit(container)
const analyser = audioService.analyzer
analyser.fftSize = 512
Function listenToMediaEvents
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private listenToMediaEvents (media: HTMLMediaElement) {
media.addEventListener('error', () => this.playNext(), true)
media.addEventListener('ended', () => {
if (commonStore.state.use_last_fm && userStore.current.preferences!.lastfm_session_key) {
Method setUpDatabase
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function setUpDatabase(): void
{
$config = [
'DB_HOST' => '',
'DB_PORT' => '',
Function startDragging
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const startDragging = (event: DragEvent, dragged: Draggable) => {
if (!event.dataTransfer) {
return
}
Function test
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('fetches the recently played songs', async () => {
const songs = factory<Song>('song', 3)
const getMock = this.mock(http, 'get').mockResolvedValue(songs)
const syncMock = this.mock(songStore, 'syncWithVault', songs)
Function maybeSetUpDatabase
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
private function maybeSetUpDatabase(): void
{
$attempt = 0;
while (true) {
- Read upRead up
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 fromRule
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function fromRule(Rule $rule): self
{
$operator = $rule->operator;
$value = $rule->value;
Function test
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('creates playlist with no songs', async () => {
const folder = factory<PlaylistFolder>('playlist-folder')
const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory<Playlist>('playlist'))
Method fromGetId3Info
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function fromGetId3Info(array $info, string $path): self
{
// We prefer ID3v2 tags over ID3v1 tags.
$tags = array_merge(
Arr::get($info, 'tags.id3v1', []),
Function test
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it.each([[0], [1]])('shuffles all if %s songs are selected', async (selectedCount: number) => {
const { emitted } = this.renderComponent(selectedCount)
await this.user.click(screen.getByTitle('Shuffle all songs'))
Function setup
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const setup = () => {
const referenceElement = extractRef(reference)
const floatingElement = extractRef(floating)
floatingElement.style.display = 'none'
Function test
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it.each<[MediaInfoDisplayMode]>([['aside'], ['full']])('renders in %s mode', async (mode) => {
await this.renderComponent(mode)
screen.getByTestId('album-info-tracks')
Function test
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('performs an excerpt search', async () => {
const result: ExcerptSearchResult = {
songs: factory<Song>('song', 3),
albums: factory<Album>('album', 3),
Function test
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it.each<[string, keyof Events, User | Song[] | Playlist | PlaylistFolder | undefined]>([
['add-user-form', 'MODAL_SHOW_ADD_USER_FORM', undefined],
['invite-user-form', 'MODAL_SHOW_INVITE_USER_FORM', undefined],
['edit-user-form', 'MODAL_SHOW_EDIT_USER_FORM', factory<User>('user')],