Skip to content

P1B: Refactor (/src/user/search.js): Function with high complexity #72

@prodiggy8

Description

@prodiggy8

Uniqueness check

  • I have searched open issues and confirmed this file + smell is not already taken.

Full path to the JavaScript file

src/user/search.js

Function(s)/scope targeted

filterAndSortUids

Relevant Qlty output

Function with high complexity (count = 11): filterAndSortUids

         137    async function filterAndSortUids(uids, data) {
         138            uids = uids.filter(uid => parseInt(uid, 10) || activitypub.helpers.isUri(uid));
         139            let filters = data.filters || [];
         140            filters = Array.isArray(filters) ? filters : [data.filters];
         141            const fields = [];
         142
              [hid 40 additional lines]

Qlty detects complexity of functions based on the number of independent paths that functions creates (eg, with if or switch statements. The more you have, the harder it is to achieve full test coverage and to read the code. This function currently has 11 of such independent paths.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions