Showing 365 of 1,033 total issues
Function processEditionSets
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function processEditionSets(
orm: any,
currentEntity: Record<string, unknown> | null | undefined,
body: ProcessEditionSetsBody,
transacting: Transaction
File search-results.js
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/*
* Copyright (C) 2015 Ohm Patel
* 2016 Sean Burke
*
* This program is free software; you can redistribute it and/or modify
Function render
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
this.state.results && this.state.results.length ?
<div id="PagerElement">
<hr className="thin"/>
Function render
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const labelElement = (
<ValidationLabel empty={this.props.empty} error={this.props.error}>
{this.props.label}
</ValidationLabel>
Function getInitState
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getInitState(
baseEntity: Entity, initRelationship: _Relationship | null | undefined
): RelationshipModalState {
if (_.isNull(initRelationship)) {
return {
Function EntityEditor
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const EntityEditor = (props: Props) => {
const {
aliasEditorVisible,
children,
heading,
Function results
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const results = this.props.results.map((result) => {
if (!result) {
return null;
}
const id = getId(result);
Function renderRelationshipSelect
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderRelationshipSelect() {
const {baseEntity, relationshipTypes} = this.props;
const otherEntity = {
bbid: _.get(this.state, ['targetEntity', 'id']),
Function validateUnifiedForm
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
function validateUnifiedForm(body:Record<string, any>):boolean {
for (const entityKey in body) {
if (Object.prototype.hasOwnProperty.call(body, entityKey)) {
const entityForm = body[entityKey];
const entityType = _.camelCase(entityForm.type);
- 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 deleteRelationships
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function deleteRelationships(orm: any, transacting: Transaction, mainEntity: any) {
const mainBBID = mainEntity.bbid;
const {relationshipSet} = mainEntity;
const otherBBIDs = [];
const otherEntities = [];
Function diffRevisionsWithParents
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function diffRevisionsWithParents(orm, entityRevisions, entityType) {
// entityRevisions - collection of *entityType*_revisions matching id
const promises = entityRevisions.map(
async (revision) => {
const dataId = revision.get('dataId');
Function dateValidator
has 46 lines of code (exceeds 25 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);
Function constructPrivsChangeStatement
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function constructPrivsChangeStatement(logData: AdminLogDataT) {
const {newPrivs, oldPrivs, targetUserId, targetUser, adminId, admin} = logData;
const {privsAdded, privsRemoved} = getPrivsChanged(newPrivs, oldPrivs);
let grantStatement = '';
Function loadEntityRelationships
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function loadEntityRelationships(entity, orm, transacting): Promise<any> {
async function getEntityWithAlias(relEntity) {
const redirectBbid = await orm.func.entity.recursivelyGetRedirectBBID(orm, relEntity.bbid, null);
const model = commonUtils.getEntityModelByType(orm, relEntity.type);
return model.forge({bbid: redirectBbid})
Function handleDelete
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function handleDelete(
orm: any, req: PassportRequest, res: $Response, HeaderModel: any,
RevisionModel: any
) {
const {entity}: {entity?: any} = res.locals;
Function cleanupOnExit
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function cleanupOnExit(cleanupPromise) {
process.on('asyncExit', () => {
cleanupPromise().then(() => {
console.log('Cleanup process finished');
process.exit(0);
Function mapDispatchToProps
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
return {
onDepthChange: (event) => dispatch(debouncedUpdateDepth(
event.target.value ? parseInt(event.target.value, 10) : null
)),
Function render
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {type, query, results} = this.state;
const querySearchParams = `q=${query}${type ? `&type=${type}` : ''}`;
return (
<div id="pageWithPagination">
Function processEdit
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function processEdit(orm, userId, revisionId) {
const revisionist = await processRevisionist(orm, userId);
const authorCreator = await processAuthorCreator(orm, userId);
const limitedEdition = await processLimitedEdition(orm, userId);
const publisher = await processPublisher(orm, userId);
Function formatEntityDiffs
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function formatEntityDiffs(diffs, entityType, entityFormatter) {
if (!diffs) {
return [];
}