huridocs/uwazi

View on GitHub

Showing 179 of 3,635 total issues

Function RenderAttachment has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export const RenderAttachment = ({ attachment }: { attachment: AttachmentSchema | ClientFile }) => {
  const { mimetype = '' } = attachment;

  const fileURL = isSerializedFile(attachment) ? prepareHTMLMediaView(attachment) : attachment.url;

Severity: Minor
Found in app/react/Attachments/components/RenderAttachment.tsx - About 1 hr 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 SortDropdownComponent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const SortDropdownComponent = ({ templates, locale }: mappedProps) => {
  const [dropdownOpen, setDropdownOpen] = useState(false);
  const menuRef = useRef(null);
  const location = useLocation();
  const [searchParams] = useSearchParams();
Severity: Minor
Found in app/react/Library/components/SortDropdown.tsx - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const {
      doc,
      docBeingEdited,
      readOnly,
Severity: Minor
Found in app/react/Documents/components/DocumentSidePanel.js - About 1 hr 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 setAccessLevelAndPermissionData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

async function setAccessLevelAndPermissionData(
  grantedPermissions: { [p: string]: { permission: PermissionSchema; access: AccessLevels[] } },
  entitiesPermissionsData: { permissions: PermissionSchema[] | undefined; published: boolean }[],
  publishedData: boolean[]
) {
Severity: Minor
Found in app/api/permissions/entitiesPermissions.ts - About 1 hr 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 uploadQueue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  private async uploadQueue(files: File[], responses: (FileType | FetchResponseError)[]) {
    if (this.aborted) {
      this.aborted = false;
      return;
    }
Severity: Minor
Found in app/react/V2/api/files/UploadService.ts - About 1 hr 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 FiltersTable has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const FiltersTable = () => {
  const { filters: loadedFilters = [], templates: loadedTemplates } = useLoaderData() as LoaderData;
  const currentFilters = useRef(loadedFilters);
  const [hasChanges, setHasChanges] = useState(false);
  const [disabled, setDisabled] = useState(false);
Severity: Minor
Found in app/react/V2/Routes/Settings/Filters/FiltersTable.tsx - About 1 hr 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 Customisation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const Customisation = () => {
  const { allowcustomJS, customCSS, customJS } = useLoaderData() as LoaderResponse;
  const [newCSS, setNewCSS] = useState<string | undefined>(undefined);
  const [newJS, setNewJS] = useState<string | undefined>(undefined);
  const [showModal, setShowModal] = useState(false);
Severity: Minor
Found in app/react/V2/Routes/Settings/Customization/Customization.tsx - About 1 hr 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 LMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const LMap = ({
  markers: pointMarkers = [],
  showControls = true,
  zoom = 6,
  layers,
Severity: Minor
Found in app/react/Map/LMap.tsx - About 1 hr 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

Consider simplifying this complex logical expression.
Open

    if (aggregation.buckets && aggregationKey !== '_types') {
      const missingBucket = aggregation.buckets.find(b => b.key === 'missing');
      const keyFilters = ((filters || {})[aggregationKey.replace('.value', '')] || {}).values || [];
      const filterNoneOrMissing =
        !keyFilters.filter(v => v !== 'any').length || keyFilters.find(v => v === 'missing');
Severity: Major
Found in app/api/search/search.js - About 1 hr to fix

    Function render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      render() {
        const { doc } = this.props;
    
        if (!doc.get('file')) {
          return null;
    Severity: Minor
    Found in app/react/Layout/DocumentLanguage.js - About 55 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 extractedMetadataChanged has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const extractedMetadataChanged = async (
      existingEntity: EntitySchema,
      newEntity: EntitySchema,
      extractors: IXExtractorType[]
    ) => {
    Severity: Minor
    Found in app/api/suggestions/eventListeners.ts - About 55 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 applyFilesOriginalnames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const applyFilesOriginalnames = (req: Request) => {
      if (req.files) {
        (req.files as Express.Multer.File[]).forEach(file => {
          const fileField = getFieldAndIndex(file.fieldname);
          if (fileField) {
    Severity: Minor
    Found in app/api/files/uploadMiddleware.ts - About 55 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 MediaModalComponent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const MediaModalComponent = ({
      isOpen,
      attachments = [],
      selectedUrl,
      entity,
    Severity: Minor
    Found in app/react/Metadata/components/MediaModal.tsx - About 55 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 contextMenuReducer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function contextMenuReducer(state = initialState, action = {}) {
      if (action.type === actions.OPEN_MENU) {
        return state.set('open', true);
      }
    
    
    Severity: Minor
    Found in app/react/ContextMenu/reducers/contextMenuReducer.js - About 55 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 applyTransformation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      applyTransformation(property, { doc, thesauri, options, template, templates }) {
        const value = doc.metadata[property.get('name')];
        const showInCard = property.get('showInCard');
    
        if (property.get('inherit')) {
    Severity: Minor
    Found in app/react/Metadata/helpers/formater.js - About 55 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 label has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      label(option: Option, isSelect = true) {
        const { optionsValue, optionsLabel, prefix } = this.props;
        const clickEvent = isSelect ? () => {} : this.toggleOptions.bind(this, option);
        return (
          <>
    Severity: Minor
    Found in app/react/Forms/components/MultiSelect.tsx - About 55 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 ConfirmationModal has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const ConfirmationModal = ({
      header,
      body,
      onAcceptClick,
      onCancelClick,
    Severity: Minor
    Found in app/react/V2/Components/UI/ConfirmationModal.tsx - About 55 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 removeDuplicationFromCollection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      async removeDuplicationFromCollection(db: Db, collectionName: string) {
        const collection = db.collection<Page | Entity>(collectionName);
        const cursor = collection.find({});
        const seenIndices: Set<string> = new Set();
        const idsToRemove: ObjectId[] = [];
    Severity: Minor
    Found in app/api/migrations/migrations/151-remove_duplicate_languages/index.ts - About 55 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 prepareRelationshipsToSave has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      async prepareRelationshipsToSave(_relationships, language) {
        const rels = this.arrangeRelationshipGroups(_relationships);
        const relsFlat = rels.flat();
        await validateConnectionSchema(relsFlat);
    
    
    Severity: Minor
    Found in app/api/relationships/relationships.js - About 55 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 filterToMatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const filterToMatch = (filter, path = 'metadata') => {
      let match;
      if (['text', 'markdown', 'generatedid'].includes(filter.type)) {
        match = textFilter(filter, path);
      }
    Severity: Minor
    Found in app/api/search/metadataMatchers.js - About 55 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