huridocs/uwazi

View on GitHub

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');
Severity: Minor
Found in app/react/App/StickyHeader.tsx - About 35 mins to fix

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';
Severity: Minor
Found in app/react/Map/MapContainer.tsx - About 35 mins to fix

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;
Severity: Minor
Found in app/react/ProtectedRoute.tsx - About 35 mins to fix

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: [
        {
Severity: Minor
Found in app/api/entities/entities.js - About 25 mins to fix

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;
Severity: Minor
Found in app/api/entities/managerFunctions.ts - About 25 mins to fix

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'
) => {
Severity: Minor
Found in app/react/I18N/actions/translationsFormActions.ts - About 25 mins to fix

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) {
Severity: Minor
Found in app/react/Metadata/components/MetadataForm.js - About 25 mins to fix

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;
Severity: Minor
Found in app/shared/data_utils/setUtils.ts - About 25 mins to fix

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);
  }

Severity: Minor
Found in app/react/Viewer/reducers/referencesReducer.js - About 25 mins to fix

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 = {
Severity: Minor
Found in app/api/relationships/groupByRelationships.js - About 25 mins to fix

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']);
Severity: Minor
Found in app/react/Pages/components/PageViewer.js - About 25 mins to fix

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) {
Severity: Minor
Found in app/api/odm/models.ts - About 25 mins to fix

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);
Severity: Minor
Found in app/api/templates.v2/database/TemplateMappers.ts - About 25 mins to fix

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):
Severity: Minor
Found in app/react/V2/Components/UI/FileIcon.tsx - About 25 mins to fix

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}`)) {
Severity: Minor
Found in app/react/Metadata/helpers/formater.js - About 25 mins to fix

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) {
Severity: Minor
Found in app/api/common.v2/database/MongoTransactionManager.ts - About 25 mins to fix

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;

Severity: Minor
Found in app/api/services/ocr/OcrManager.ts - About 25 mins to fix

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;
Severity: Minor
Found in app/react/Auth/components/NeedAuthorization.tsx - About 25 mins to fix

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
Severity: Minor
Found in app/api/services/tasksmanager/DistributedLoop.ts - About 25 mins to fix

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);
Severity: Minor
Found in app/react/V2/atoms/store.ts - About 25 mins to fix

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

Severity
Category
Status
Source
Language