Showing 365 of 1,033 total issues
Function getEntityRelations
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getEntityRelations(entityType) {
const authorRelations = [
'defaultAlias.language',
'disambiguation',
'authorType',
Function EditionSection
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function EditionSection({
depthValue,
editionFormats,
editionStatuses,
formatValue,
- 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 14 (exceeds 5 allowed). Consider refactoring. Open
function mapDispatchToProps(dispatch):ISBNDispatchProps {
let autoAddedISBN:dispatchResultProps|null;
function onChange(value:string, autoISBN = false) {
const isbn10rgx = new
RegExp('^(?:ISBN(?:-10)?:?●)?(?=[0-9X]{10}$|(?=(?:[0-9]+[-●]){3})[-●0-9X]{13}$)[0-9]{1,5}[-●]?[0-9]+[-●]?[0-9]+[-●]?[0-9X]$');
- 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 getEntityDiff
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
static getEntityDiff(diff) {
let mergeBadge = null;
let deleteBadge = null;
if (diff.isDeletion) {
if (diff.entityRevision.isMerge) {
Function init
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function init(app, config) {
const influxConfig = config.influx;
const influx = new Influx.InfluxDB({
database: influxConfig.database || 'bookbrainz',
Function renderEntitySelect
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
renderEntitySelect() {
const {baseEntity, relationshipTypes} = this.props;
const {targetEntity} = this.state;
const types = getValidOtherEntityTypes(relationshipTypes, baseEntity);
if (!types.length) {
Function getBrowsedRelationships
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getBrowsedRelationships(orm, locals, browsedEntityType,
getEntityInfoMethod, fetchRelated, filterRelationshipMethod) {
const {entity, relationships} = locals;
if (!relationships.length > 0) {
Function render
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {query, results} = this.state;
const querySearchParams = `q=${query}&type=editor`;
return (
<Card>
Function AdminLogsTable
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AdminLogsTable(props) {
const {results, tableHeading} = props;
return (
<div>
<div>
Function DevelopPage
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function DevelopPage(): JSX.Element {
return (
<div>
<div className="page-header">
<h1>Developing with BookBrainz</h1>
Function formatAliasModified
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function formatAliasModified(change) {
if (change.path.length > 3 && change.path[3] === 'name') {
return [
base.formatChange(
change,
Function promises
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
async (revision) => {
const dataId = revision.get('dataId');
const revisionEntity = revision.related('entity');
const entityBBID = revisionEntity.get('bbid');
const entity = await orm.func.entity.getEntity(orm, entityType, entityBBID);
Function handleAddToNewCollection
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleAddToNewCollection(evt) {
evt.preventDefault();
if (!this.isValid()) {
this.setState({
Function generateRelationshipSelection
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function generateRelationshipSelection(
relationshipTypes: Array<RelationshipType>,
entityA: Entity,
entityB: Entity
): Array<RelationshipWithLabel> {
Function alertPromise
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
let alertPromise = editorEntityVisitPromise.then((visitAlert) => {
let alertIds = [];
if (visitAlert.alert) {
alertIds = alertIds.concat(visitAlert.alert.split(',').map(
(id) => parseInt(id, 10)
Function SearchEntityCreate
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SearchEntityCreate(props:SearchEntityCreateProps) {
const {type, nextId, onModalOpen, onModalClose, onSubmitEntity, rowId, onOpenCallback, ...rest} = props;
const createLabel = React.useCallback((input) => `Create ${type} "${input}"`, [type]);
const [showModal, setShowModal] = React.useState(false);
const getNewOptionData = React.useCallback((_, label) => ({
Function getEntityFetchPropertiesByType
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getEntityFetchPropertiesByType(entityType) {
switch (entityType) {
case 'Author':
return ['authorType', 'beginArea', 'endArea', 'gender'];
case 'Edition':
Function identifierTypeCreateOrEditHandler
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function identifierTypeCreateOrEditHandler(req, res) {
try {
const {IdentifierType} = req.app.locals.orm;
let newIdentifierType;
let method;
Function getAssociatedEntityRevisions
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function getAssociatedEntityRevisions(revisions, orm) {
const revisionIDs = revisions.map(({revisionId}) => revisionId);
const RevisionModels = getRevisionModels(orm);
const {Entity} = orm;
for (let i = 0; i < RevisionModels.length; i++) {
Function getEntityRelationships
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function getEntityRelationships(entity: any) {
return _.isNil(entity) ? null :
{
bbid: _.get(entity, 'bbid', null),
relationships: _.get(entity, 'relationshipSet.relationships', []).map((relationship) => {
- 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"