huridocs/uwazi

View on GitHub

Showing 170 of 3,578 total issues

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

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

const FiltersSidepanel = ({
  showSidepanel,
  setShowSidepanel,
  onSave,
  availableTemplates,

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

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 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 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

    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 getFilesForTraining has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    async function getFilesForTraining(templates: ObjectIdSchema[], property: string) {
      const propertyType = await getPropertyType(templates, property);
      const entities = await entitiesModel.getUnrestricted(
        entityForTrainingQuery(templates, property, propertyType),
        `sharedId metadata.${property} language`
    Severity: Minor
    Found in app/api/services/informationextraction/getFiles.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 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 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 MenuConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const MenuConfig = () => {
      const links = useLoaderData() as ClientSettingsLinkSchema[];
      const [isSidepanelOpen, setIsSidepanelOpen] = useState(false);
      const setNotifications = useSetAtom(notificationAtom);
      const revalidator = useRevalidator();
    Severity: Minor
    Found in app/react/V2/Routes/Settings/MenuConfig/MenuConfig.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 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 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 limitRelationshipResults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const limitRelationshipResults = (results, entitySharedId, hubsLimit) => {
      const hubs = conformRelationships(results.rows, entitySharedId).toJS();
      results.totalHubs = hubs.length;
      results.requestedHubs = Number(hubsLimit);
    
    
    Severity: Minor
    Found in app/api/relationships/relationships.js - About 45 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

    Avoid deeply nested control flow statements.
    Open

              if (!openTokens) {
                if (
                  str.slice(
                    matchStartIndex - escapeCode.length - opener.length,
                    matchStartIndex - opener.length
    Severity: Major
    Found in app/react/utils/markdownEscapedValues.js - About 45 mins to fix

      Function validateHeader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const validateHeader = async (file: ImportFile, options: ValidateHeaderOptions) => {
        const headerOptions = options.required_headers || options.column_number;
        if (!headerOptions) return;
      
        const header = await peekHeaders(await file.readStream());
      Severity: Minor
      Found in app/api/csv/csv.ts - About 45 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 requestDatasets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const requestDatasets = (datasets, requestParams) =>
        Promise.all(
          Object.keys(datasets).map(name => {
            if (datasets[name].query) {
              return api
      Severity: Minor
      Found in app/react/Markdown/markdownDatasets.js - About 45 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 startTraining has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function startTraining(thesaurus: ThesaurusSchema) {
        if (!(await IsTopicClassificationReachable())) {
          throw new Error(`Topic Classification server is unreachable (waited ${RPC_DEADLINE_MS} ms)`);
        }
        const flattenValues = thesaurus.values!.reduce(
      Severity: Minor
      Found in app/api/topicclassification/api.ts - About 45 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