Showing 13 of 21 total issues
Function Home
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function Home() {
const [error, setError] = React.useState<any>(null);
const [items, setItems] = React.useState<any[] | null>(null);
const [showCreateModal, setShowCreateModal] = React.useState(false);
const [newTitle, setNewTitle] = React.useState('');
Function handleJWT
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
const handleJWT = (req: any, res: any, next: any, roles: any) => async (err: any, user: any, info: any) => {
const error = err || info;
const logIn: any = Bluebird.promisify(req.logIn);
const apiError = new APIError({
message: error ? error.message : 'Unauthorized',
- 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 render
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { action, actionRegister, renderTitle, showError = true } = this.props;
const { mode, username, password, name, error } = this.state;
let formAction = mode === Mode.LOGIN && action ? action : '';
Function apiJson
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export async function apiJson({ req, res, data, model, meta = {}, json = false }: apiJsonTypes) {
const queryObj = getPageQuery(req.query);
const metaData = { ...queryObj, ...meta };
if (model) {
- 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 findAndGenerateToken
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async findAndGenerateToken(options: any) {
const { email, password, refreshObject } = options;
if (!email) {
throw new APIError({ message: 'An email is required to generate a token' });
}
- 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 Login
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function Login({ onLogin }: { onLogin?: () => void }) {
const [errorMsg, setErrorMsg] = React.useState('');
const navigate = useNavigate();
const onSubmit = async (formData: any) => {
- 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 registerValidSW
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
Function handleJWT
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleJWT = (req: any, res: any, next: any, roles: any) => async (err: any, user: any, info: any) => {
const error = err || info;
const logIn: any = Bluebird.promisify(req.logIn);
const apiError = new APIError({
message: error ? error.message : 'Unauthorized',
Function App
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function App() {
const [loggedInEmail, setLoggedInEmail] = React.useState('');
const refreshEmail = () => {
const { userEmail } = getLoginData();
Function getSortQuery
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function getSortQuery(sortStr: string, defaultKey = 'createdAt') {
let arr = [sortStr || defaultKey];
if (sortStr && sortStr.indexOf(',')) {
arr = sortStr.split(',');
}
- 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 Home
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function Home() {
const [error, setError] = React.useState<any>(null);
const [items, setItems] = React.useState<any[] | null>(null);
const [showCreateModal, setShowCreateModal] = React.useState(false);
const [newTitle, setNewTitle] = React.useState('');
- 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
Avoid too many return
statements within this function. Open
return next();
Function render
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
render() {
const { action, actionRegister, renderTitle, showError = true } = this.props;
const { mode, username, password, name, error } = this.state;
let formAction = mode === Mode.LOGIN && action ? action : '';
- 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"