GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

src/util/sorter.js   A
last analyzed

Size

Lines of Code 23

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 23
rs 10
noi 1
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A sorter.js ➔ ??? 0 3 1
1
import { SORT_DIRECTIONS } from '../constants/GridConstants';
2
3
export class Sorter {
4
    constructor() {
5
6
    }
7
8
    sortBy(name, direction, datasource) {
9
        return datasource.data.sort((a, b) => {
10
11
            if (a.get(name) < b.get(name) && direction) {
12
                return direction === SORT_DIRECTIONS.ASCEND ? 1 : -1;
13
            }
14
15
            else if (a.get(name) > b.get(name)) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if a.get(name) > b.get(name) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
16
                return direction === SORT_DIRECTIONS.ASCEND ? -1 : 1;
17
            }
18
19
        });
20
    }
21
}
22
23
export default new Sorter();
24