Showing 143 of 663 total issues
Function CommandPaletteContainer
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const CommandPaletteContainer: React.FC = () => {
const { t } = useTranslation('command-palette');
const [isOpen, setOpen] = useState(false);
const [input, setInput] = useState('');
const inputRef = useRef<Input>();
Function addPlaylistFromFile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function addPlaylistFromFile(filePath, t) {
return async dispatch => {
if (!filePath || typeof filePath !== 'string') {
dispatch(error(t('import-fail-title'), t('error-empty-data'), null, null));
return;
Function Toast
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Toast = (props: ToastProps) => {
return (
<div
className={cx(
common.nuclear,
Function QueueReducer
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function QueueReducer(state = defaultState, action) {
switch (action.type) {
case Queue.ADD_QUEUE_ITEM:
return {
...state,
Function mockAlbumResult
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function mockAlbumResult() {
global.fetch = jest.fn(() =>
Promise.resolve({
json: jest.fn(() => ({
'resultCount': 1,
Function mountComponent
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const mountComponent = (initialStore?: AnyProps) => {
const initialState = initialStore ||
buildStoreState()
.withArtistDetails()
.withPlaylists([{
Function loadUserPlugin
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function loadUserPlugin(path) {
return async (dispatch, getState) => {
dispatch(loadUserPluginStart(path));
try {
const api = createApi();
Function equalizerRouter
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function equalizerRouter(store: Store, rendererWindow: BrowserWindow['webContents']): ISwaggerizedRouter {
const router = express.Router() as ISwaggerizedRouter;
swagger.swaggerize(router);
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
<Route render={({ location }) => {
return (
<MainLayout>
Function onAccept
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onAccept = (w: WebviewTag, handleClose: CloseCallback) => {
if (w !== null) {
w.addEventListener('dom-ready', () => {
w.addEventListener('ipc-message', event => {
switch (event.channel) {
Function fetchAllFmFavorites
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function fetchAllFmFavorites() {
const storage = store.get('lastFm');
if (storage) {
return async dispatch => {
dispatch({ type: ImportFavs.LASTFM_FAV_IMPORT_START });
Function render
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
<div
style={{
background: '#282a36',
Function ImportFavsReducer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function ImportFavsReducer(state=initialState, action) {
switch (action.type) {
case ImportFavs.FAV_IMPORT_INIT:
return Object.assign({}, state, {
lastFmFavImportStatus: action.payload.lastFmFavImportStatus,
Function MiniPlayerContainer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const MiniPlayerContainer: React.FC = () => {
const seekbarProps = useSeekbarProps();
const playerControlsProps = usePlayerControlsProps();
const trackInfoProps = useTrackInfoProps();
const volumeControlsProps = useVolumeControlsProps();
Function fetchArtistDetails
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async fetchArtistDetails(artistId: string): Promise<ArtistDetails> {
const AudiusInfo: AudiusArtistInfo = (await ((await Audius.getArtist(this.apiEndpoint, artistId)).json())).data;
AudiusInfo.name = cleanName(AudiusInfo.name);
const lastFmInfo: LastFmArtistInfo = (await (await this.lastfm.getArtistInfo(AudiusInfo.name)).json()).artist;
Function getSegments
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function getSegments (videoID: VideoID, categories?: Category[]): Promise<Segment[]> {
let query = `?videoID=${videoID}`;
if (!categories) {
query += `&categories=${JSON.stringify(ALL_CATEGORIES)}`;
Function getEntries
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getEntries(request?: ListeningHistoryRequest): Promise<PagingResult<ListeningHistoryEntry>> {
const qb = this.listeningHistoryRepository.createQueryBuilder('entry');
if (request?.artist) {
qb.andWhere(`entry.artist = '${request.artist}'`);
Function PlayQueue
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
const PlayQueue: React.FC<PlayQueueProps> = ({
actions: {
queueDrop,
repositionSong,
addToDownloads,
- 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 fetchAcousticIdBatch
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fetchAcousticIdBatch(metas: NuclearMeta[], onProgress?: ProgressHandler): Promise<void[]> {
let scanProgress = 0;
const scanTotal = metas.length;
this.logger.log(`start fetching metadata from acoustic-id api for ${scanTotal} tracks`);
Function EqualizerViewContainer
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const EqualizerViewContainer: React.FC = () => {
const equalizer = useSelector((state: RootState) => state.equalizer);
const preset = equalizer.presets[equalizer.selected];
const dispatch = useDispatch();
const actions = useMemo(() => bindActionCreators(EqualizerActions, dispatch), [dispatch]);