Showing 134 of 387 total issues
Function test
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('does not show a badge when current user is not the collaborator', async () => {
const currentUser = factory('user')
this.be(currentUser).renderComponent({
collaborator: factory('playlist-collaborator', { id: currentUser.id + 1 }),
Function test
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('toggles one song', async () => {
const addMock = this.mock(favoriteStore, 'add')
const removeMock = this.mock(favoriteStore, 'remove')
const postMock = this.mock(http, 'post')
Function test
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('renders', async () => expect((await this.renderComponent()).html()).toMatchSnapshot())
it('plays all', async () => {
const songs = factory('song', 10)
Function test
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('initializes the store', () => {
const applyMock = this.mock(themeStore, 'applyThemeFromPreference')
themeStore.init()
Function test
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('renders', async () => expect((await this.renderComponent()).html()).toMatchSnapshot())
it('plays all', async () => {
const songs = factory('song', 10)
Function update
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
update () {
this.analyzer.getByteFrequencyData(this.audioBuffer)
let bass = 0.0; let mid = 0.0; let high = 0.0
if (this.audioBuffer[0] === 0) {
- 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
Function useErrorHandler
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
export const useErrorHandler = (driver: ErrorMessageDriver = 'toast') => {
const { toastError } = useMessageToaster()
const { showErrorDialog } = useDialogBox()
const showError = (message: string) => driver === 'toast' ? toastError(message) : showErrorDialog(message)
- 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
Function listenToMediaEvents
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private listenToMediaEvents (media: HTMLMediaElement) {
media.addEventListener('error', () => this.playNext(), true)
media.addEventListener('ended', () => {
if (
Function test
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('renders', () => {
playlistStore.state.playlists = [
factory('playlist', { name: 'Foo' }),
factory('playlist', { name: 'Bar' }),
Function test
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it('fetches the artist info', async () => {
const artist = artistStore.syncWithVault(factory('artist', { id: 42 }))[0]
const artistInfo = factory('artist-info')
const getMock = this.mock(http, 'get').mockResolvedValue(artistInfo)
Function useDraggable
has 44 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
}
Function test
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected test () {
it.each<[string, keyof Events, User | Playable[] | 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')],
Function useUpload
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const useUpload = () => {
const { toastSuccess, toastWarning } = useMessageToaster()
const { go, isCurrentScreen } = useRouter()
const { currentUserCan } = usePolicies()
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 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.active_extra_panel_tab = 'YouTube'
Function usePlaylistManagement
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const usePlaylistManagement = () => {
const { handleHttpError } = useErrorHandler('dialog')
const { toastSuccess } = useMessageToaster()
const inflect = (playables: Playable[]) => {
Function startDragging
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const startDragging = (event: DragEvent, dragged: Draggable) => {
if (!event.dataTransfer) {
return
}
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