Showing 179 of 3,635 total issues
Function eventHandler
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const eventHandler = (self: any, stickyElementSelector: string, event: Event) => {
if (self && self.current && event.target && event.target instanceof Element) {
const { current } = self;
const stickyElement: HTMLElement = current.querySelector(stickyElementSelector);
current.classList.remove('sticky');
- 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 MapComponent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const MapComponent = ({ collectionSettings, templates, ...props }: ComponentProps) => {
const startingPoint = collectionSettings?.get('mapStartingPoint')?.toJS() || [
{ lat: 46, lon: 6 },
];
const tilesProvider = collectionSettings?.get('tilesProvider') || 'mapbox';
- 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 ProtectedRoute
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const ProtectedRoute = ({
children,
allowedRoles,
}: {
children: ReactElement;
- 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 deleteFromMetadata
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async deleteFromMetadata(deletedId, propertyContent, propTypes) {
const includesRelationships = propTypes.includes(propertyTypes.relationship);
const allTemplates = await templates.get({
$or: [
{
- 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 bindAttachmentToMetadataProperty
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const bindAttachmentToMetadataProperty = (
_values: MetadataObjectSchema[],
attachments: FileType[]
) => {
const values = _values;
- 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 prepareFormValues
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const prepareFormValues = (
translations: IImmutable<ClientTranslationSchema[]> | ClientTranslationSchema[],
context: string,
defaultLocale: string = 'en'
) => {
- 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 mapStateToProps
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const mapStateToProps = (state, ownProps) => {
const entityModel = ownProps.model.split('.').reduce((o, i) => o[i], state);
const { attachments, sharedId } = entityModel;
let progress = state.attachments.progress.get('NEW_ENTITY');
if (sharedId) {
- 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 setsEqual
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function setsEqual<T>(_set1: ArrayOrSet<T>, _set2: ArrayOrSet<T>): boolean {
const set1 = _set1 instanceof Set ? _set1 : new Set(_set1);
const set2 = _set2 instanceof Set ? _set2 : new Set(_set2);
if (set1.size !== set2.size) {
return 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 referencesReducer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export default function referencesReducer(state = initialState, action = {}) {
if (action.type === types.SET_REFERENCES) {
return Immutable.fromJS(action.references);
}
- 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 getGroupData
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function getGroupData(reference, groupedReferences, _templates, relationTypes) {
const key = reference.template ? reference.template.toString() : null;
let groupData = groupedReferences.find(ref => ref.key === key);
if (!groupData) {
groupData = {
- 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
render() {
const { page, itemLists, datasets, error, setBrowserTitle } = this.props;
const lists = itemLists.toJS();
const originalText = page.getIn(['metadata', 'content']) || '';
const scriptRendered = page.getIn(['scriptRendered']);
- 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 QueryForEach
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export async function QueryForEach(batchSize: number, fn: (e: EntitySchema) => Promise<void>) {
let lastId;
let batch;
// eslint-disable-next-line no-constant-condition
while (true) {
- 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 propertyToApp
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function propertyToApp(property: PropertyDBO, _templateId: TemplateDBO['_id']): Property {
const templateId = MongoIdHandler.mapToApp(_templateId);
const propertyId = property._id?.toString() || MongoIdHandler.generate();
if ('isCommonProperty' in property && property.isCommonProperty) {
return new CommonProperty(propertyId, property.type, property.name, property.label, templateId);
- 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 FileIcon
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const FileIcon = ({ mimetype = '', filename, altText, className }: FileIconProps) => {
let type: 'image' | 'pdf' | 'media' | 'other';
switch (true) {
case /^image\//.test(mimetype):
- 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 formatMetadataSortedProperties
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const formatMetadataSortedProperties = (metadata, sortedProperties) =>
metadata.map(prop => {
const newProp = { ...prop };
newProp.sortedBy = false;
if (sortedProperties.includes(`metadata.${prop.name}`)) {
- 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 commitWithRetry
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private async commitWithRetry() {
try {
await this.session!.commitTransaction();
this.finished = true;
} catch (error) {
- 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 getStatus
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const getStatus = async (file: EnforcedWithId<FileType>) => {
const [record] = await getForSourceOrTargetFile(file);
const status = record ? record.status : OcrStatus.NONE;
- 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 checkWritePermissions
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const checkWritePermissions = (
entities: EntitySchema[] = [],
user: any | undefined = undefined
) => {
let granted = user !== undefined && user.has('role') && entities.length > 0;
- 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 lockTask
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async lockTask(): Promise<void> {
try {
const lock = await this.redlock.lock(
this.lockName,
this.maxLockTime + this.delayTimeBetweenTasks
- 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 hydrateAtomStore
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const hydrateAtomStore = (data: AtomStoreData) => {
if (data.ciMatomoActive) atomStore.set(ciMatomoActiveAtom, data.ciMatomoActive);
if (data.globalMatomo) atomStore.set(globalMatomoAtom, { ...data.globalMatomo });
if (data.settings) atomStore.set(settingsAtom, data.settings);
if (data.thesauri) atomStore.set(thesauriAtom, data.thesauri);
- 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"