Showing 365 of 1,033 total issues
Function render
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const messageComponent =
this.state.message.text ? (
<Alert
className="margin-top-1"
Function render
has 126 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {entity} = this.props;
const {note} = this.state;
this.entityUrl = `/${_kebabCase(entity.type)}/${entity.bbid}`;
File identifier-type.tsx
has 372 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
* Copyright (C) 2023 Shivam Awasthi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Function RelationshipTypeEditor
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
Open
function RelationshipTypeEditor({relationshipTypeData, parentTypes, attributeTypes}: RelationshipTypeEditorPropsT) {
const [formData, setFormData] = useState<RelationshipTypeDataT>(relationshipTypeData);
// State for the ParentType modal
const [showModal, setShowModal] = useState<boolean>(false);
- 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 HelpPage
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function HelpPage(): JSX.Element {
const IRCLink = 'https://kiwiirc.com/nextclient/irc.libera.chat/?#bookbrainz';
const userGuideLink =
'https://bookbrainz-user-guide.readthedocs.io/';
File middleware.ts
has 367 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
* Copyright (C) 2015 Ben Ockmore
* 2015-2016 Sean Burke
* 2021 Akash Gupta
* 2022 Ansh Goyal
Function crossSliceReducer
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function crossSliceReducer(state:State, action:Action) {
const {type} = action;
let intermediateState = state;
const activeEntityState = {
aliasEditor: state.get('aliasEditor'),
Function render
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {revision, diffs, user} = this.props;
let regularDiffs = diffs;
let mergeDiffDivs;
Function render
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
disambiguationDefaultValue,
entityType,
exactMatches: immutableExactMatches,
Function editionToFormState
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function editionToFormState(edition) {
/** The front-end expects a language id rather than the language object. */
const aliases = edition.aliasSet ?
edition.aliasSet.aliases.map(({languageId, ...rest}) => ({
...rest,
Function entitiesToFormState
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function entitiesToFormState(entities: any[]) {
const [targetEntity, ...otherEntities] = entities;
const aliases: any[] = entities.reduce((returnValue, entity) => {
if (Array.isArray(_.get(entity, 'aliasSet.aliases'))) {
return returnValue.concat(
Function SearchAdminPage
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function SearchAdminPage() {
const [loading, setLoading] = useState(false);
const [errorMessage, setErrorMessage] = useState<string>();
const [success, setSuccess] = useState(false);
const indexEntity = useCallback(async (entityType?:string) => {
Function RevisionsTable
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function RevisionsTable(props) {
const {results, showEntities, showRevisionNote, showRevisionEditor, tableHeading} = props;
return (
<div>
<div>
Function render
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const loadingElement =
this.state.waiting ? <LoadingSpinner/> : null;
const genderOptions = this.state.genders.map((gender) => ({
id: gender.id,
Function processSingleEntity
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function processSingleEntity(formBody, JSONEntity, reqSession,
entityType, orm:any, editorJSON, derivedProps, isMergeOperation, transacting):Promise<any> {
const {Entity, Revision} = orm;
let body = sanitizeBody(formBody);
let currentEntity: {
Function displayEntity
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function displayEntity(req: PassportRequest, res: $Response) {
const {orm}: {orm?: any} = req.app.locals;
const {AchievementUnlock, EditorEntityVisits} = orm;
const {locals: resLocals}: {locals: any} = res;
const {entity}: {entity: any} = resLocals;
File merge.ts
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
* Copyright (C) 2019 Nicolas Pelletier
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
File collection.js
has 322 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
* Copyright (C) 2020 Prabal Singh
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Function render
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
if (this.state.entities.length === 0) {
this.handleAddEntity();
}
Function dateValidator
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
export function dateValidator(dayObj, monthObj, yearObj) {
const year = Number.parseInt(yearObj, 10);
const month = Number.parseInt(monthObj, 10);
const day = Number.parseInt(dayObj, 10);
- 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"