huridocs/uwazi

View on GitHub

Showing 179 of 3,635 total issues

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

  static getOrCreate(name: string, type: string) {
    let task = this.taskInstances[name];
    if (!task || ['done', 'failed'].includes(task.status.state)) {
      const TaskClass = this.taskClasses[type];
      if (!TaskClass) {
Severity: Minor
Found in app/shared/tasks/tasks.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 getFieldError has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const getFieldError = (field: 'username' | 'password' | 'email', type?: string) => {
  if (field === 'username') {
    switch (type) {
      case 'required':
        return 'Username is required';
Severity: Minor
Found in app/react/V2/Routes/Settings/Users/components/UserFormSidepanel.tsx - 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 OCRStatus has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const OCRStatus = ({ file, ocrIsToggled, locale, loadDocument }: ComponentProps) => {
  if (!ocrIsToggled) return null;

  const [ocrStatus, setOcrStatus] = useState({ status: 'loading', lastUpdated: Date.now() });

Severity: Minor
Found in app/react/Viewer/components/OCRStatus.tsx - 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 dndSortHandler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const dndSortHandler = <T extends TableRow<T>>({
  currentState,
  dataIds,
  activeId,
  overId,
Severity: Minor
Found in app/react/V2/Components/UI/Table/helpers.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 IXSuggestionsLoader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  (headers?: IncomingHttpHeaders): LoaderFunction =>
  async ({ params: { extractorId }, request }) => {
    if (!extractorId) throw new Error('extractorId is required');
    const searchParams = new URLSearchParams(request.url.split('?')[1]);
    const filter: any = { extractorId };
Severity: Minor
Found in app/react/V2/Routes/Settings/IX/IXSuggestions.tsx - 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 RelationshipTypes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const RelationshipTypes = () => {
  const relationshipTypes = useLoaderData() as Relationships[];
  const revalidator = useRevalidator();

  const [isSidepanelOpen, setIsSidepanelOpen] = useState(false);
Severity: Minor
Found in app/react/V2/Routes/Settings/RelationshipTypes/RelationshipTypes.tsx - 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 MenuForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const MenuForm = ({ closePanel, submit, linkToEdit, links = [] }: MenuFormProps) => {
  const groups = useRef<OptionSchema[]>([
    { label: t('System', 'No Group', 'No Group', false), value: '', key: '-' },
  ]);

Severity: Minor
Found in app/react/V2/Routes/Settings/MenuConfig/components/MenuForm.tsx - 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 UserFormSidepanel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const UserFormSidepanel = ({
  showSidepanel,
  setShowSidepanel,
  setSelected,
  selectedUser,
Severity: Minor
Found in app/react/V2/Routes/Settings/Users/components/UserFormSidepanel.tsx - 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 EditThesaurus has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const EditThesaurus = () => {
  const navigate = useNavigate();
  const thesaurus = useLoaderData() as ClientThesaurus;
  const templates = useAtomValue(templatesAtom);
  const [showNavigationModal, setShowNavigationModal] = useState(false);
Severity: Minor
Found in app/react/V2/Routes/Settings/Thesauri/EditThesaurus.tsx - 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 TwoFactorSetup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const TwoFactorSetup = ({ closePanel, isOpen }: TwoFactorSetupProps) => {
  const [token, setToken] = useState('');
  const [_secret, setSecret] = useState('');
  const [_otpauth, setOtpauth] = useState('');
  const setNotifications = useSetAtom(notificationAtom);
Severity: Minor
Found in app/react/V2/Routes/Settings/Account/Components/TwoFactorSetup.tsx - 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

Consider simplifying this complex logical expression.
Open

        if (entity && entity.template) {
          entity.metadata = entity.metadata || {};
          const template = _templates.find(t => t._id.toString() === entity.template.toString());

          const relationshipProperties = template.properties.filter(p => p.type === 'relationship');
Severity: Major
Found in app/api/entities/entities.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        if (
          labeledValue ||
          (propertyIsSelect(propertyType) && currentValue) ||
          (propertyIsMultiValued(propertyType) &&
            Array.isArray(currentValue) &&
    Severity: Major
    Found in app/shared/getIXSuggestionState.ts - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          if (!scriptIsPresent.current) {
            const script = document.createElement('script');
            const hasUserMatomo = Boolean(id && url);
            const hasGlobalMatomo = Boolean(globalUrl && globalId);
      
      
      Severity: Major
      Found in app/react/V2/Components/Analitycs/Matomo.tsx - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if (
                doc &&
                doc.sharedId &&
                doc.language &&
                doc._id &&
        Severity: Major
        Found in app/api/migrations/migrations/151-remove_duplicate_languages/index.ts - About 40 mins to fix

          Function getThesauriTranslations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const getThesauriTranslations = async (db: Db) => {
            const translationsCollection = db.collection<Translation>('translationsV2');
            const translationsCursor = translationsCollection.find({ 'context.type': 'Thesaurus' });
            while (await translationsCursor.hasNext()) {
              const translation = await translationsCursor.next();

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

          export const permissionsFilters = (query: SearchQuery) => {
            const user = permissionsContext.getUserInContext();
            const publishedFilter = query.filter?.hasOwnProperty('published');
          
            return [
          Severity: Minor
          Found in app/api/search.v2/permissionsFilters.ts - 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            render() {
              const {
                model,
                template,
                templateOptions,
          Severity: Minor
          Found in app/react/Metadata/components/MetadataForm.js - 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 filterIsEmpty has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function filterIsEmpty(value) {
            if (value && value.values && !value.values.length) {
              return true;
            }
          
          
          Severity: Minor
          Found in app/react/Library/actions/libraryActions.js - 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 singleUpload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            (type?: FileType['type'], tmpStorage: multer.StorageEngine = defaultStorage) =>
            async (req: Request, res: Response, next: NextFunction) => {
              try {
                await new Promise<void>((resolve, reject) => {
                  multer({ storage: tmpStorage }).single('file')(req, res, err => {
          Severity: Minor
          Found in app/api/files/uploadMiddleware.ts - 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

          Severity
          Category
          Status
          Source
          Language