Showing 365 of 1,033 total issues
Function getEditorActivity
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getEditorActivity(editorId, startDate, Revision, endDate = Date.now()) {
if (!isValid(startDate)) {
throw new Error('Start date is invalid');
}
if (!isValid(endDate)) {
Function render
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
render() {
const messageComponent =
this.state.message.text ? (
<Alert
className="margin-top-1"
- 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 processSingleEntity
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. 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: {
- 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 editionToFormState
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. 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,
- 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 processEditionSets
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function processEditionSets(
orm: any,
currentEntity: Record<string, unknown> | null | undefined,
body: ProcessEditionSetsBody,
transacting: Transaction
- 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 getProgress
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function getProgress(achievementId, editorId, orm) {
const revisionist = [1, 2, 3];
if (revisionist.includes(achievementId)) {
const {Editor} = orm;
const editor = await new Editor({id: editorId})
- 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 addAuthorCreditRow
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function addAuthorCreditRow(state, newItemKey) {
// Add a new empty author credit row
let returnedState = state.set(newItemKey, EMPTY_CREDIT_ROW);
const autoJoinPhraseRegex = /^(| & |, )$/;
- 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 mapDispatchToProps
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function mapDispatchToProps(dispatch, {submissionUrl}):ContentTabDispatchProps {
const type = 'Work';
return {
bulkAddSeriesItems: (data) => dispatch(addBulkSeriesItems(data)),
onAddSeriesItem: (data) => dispatch(addSeriesItem(data, data.rowID)),
- 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 RegistrationAuth
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function RegistrationAuth() {
return (
<div>
<div className="page-header"><h1>Register</h1></div>
<p>
Function renderDuplicateAlert
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
renderDuplicateAlert(warnIfExists, disambiguationDefaultValue, exactMatches, entityType, lgCol) {
return (
<Col lg={lgCol}>
{isRequiredDisambiguationEmpty(
warnIfExists,
Function transformNewForm
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function transformNewForm(data) {
const aliases = entityRoutes.constructAliases(
data.aliasEditor, data.nameSection
);
Function dateIsBefore
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function dateIsBefore(beginValue: string | DateObject, endValue: string | DateObject): boolean {
const beginDateObject = ISODateStringToObject(beginValue);
const endDateObject = ISODateStringToObject(endValue);
if (isNullDate(beginDateObject) || isNullDate(endDateObject) || !validateDate(beginDateObject).isValid ||
!validateDate(endDateObject).isValid) {
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const option = this.getSafeOptionValue(this.props.data);
const {disambiguation, text, type, unnamedText, language, authors, __isNew__} = option;
const nameComponent = text || <i>{unnamedText}</i>;
const externalLinkComponent = !__isNew__ &&
Function renderActivityGraph
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
renderActivityGraph() {
const {activityData, totalRevisions} = this.props.editor;
const months = keys(activityData);
const numberOfRevisions = values(activityData);
Function handleRemoveEntities
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleRemoveEntities() {
if (this.state.selectedEntities.length) {
const bbids = this.state.selectedEntities;
const submissionUrl = `/collection/${this.props.collection.id}/remove`;
request.post(submissionUrl)
Function getOrderedRevisionsForEntityPage
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getOrderedRevisionsForEntityPage(orm: any, from: number, size: number, RevisionModel, bbid: string) {
const otherMergedBBIDs = await recursivelyGetMergedEntitiesBBIDs(orm, [bbid]);
const revisions = await new RevisionModel()
.query((qb) => {
Function makeSortName
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeSortName(name: string): string {
const articles = ['a', 'an', 'the', 'los', 'las', 'el', 'la'];
const suffixes = [
'i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x', 'xi',
'xii', 'xiii', 'xiv', 'xv', 'jr', 'junior', 'sr', 'senior', 'phd', 'md',
Function getOrderedRevisionForEditorPage
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getOrderedRevisionForEditorPage(from, size, req) {
const {Editor, Revision} = req.app.locals.orm;
// If editor isn't present, throw an error
await new Editor({id: req.params.id})
Function addAuthorCreditRow
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addAuthorCreditRow(state, newItemKey) {
// Add a new empty author credit row
let returnedState = state.set(newItemKey, EMPTY_CREDIT_ROW);
const autoJoinPhraseRegex = /^(| & |, )$/;
Function processSingleEntity
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function processSingleEntity(formBody, JSONEntity, reqSession,
entityType, orm:any, editorJSON, derivedProps, isMergeOperation, transacting):Promise<any> {