Showing 143 of 652 total issues
Function createPopup
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createPopup() {
const {
url,
width,
height,
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 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 Toast
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Toast = (props: ToastProps) => {
return (
<div
className={cx(
common.nuclear,
Function PlayQueue
has a Cognitive Complexity of 11 (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 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 mountComponent
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const mountComponent = (initialStore?: AnyProps) => {
const initialState = initialStore ||
buildStoreState()
.withArtistDetails()
.withPlaylists([{
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 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 render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
<Route render={({ location }) => {
return (
<MainLayout>
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 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 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 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 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 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 renderPlugins
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private renderPlugins() {
const { children } = this.props;
if (Array.isArray(children)) {
const flatChildren = children.flat() as ReactElement[];
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]);