INTO-CPS-Association/DTaaS

View on GitHub

Showing 144 of 198 total issues

File Store.test.ts has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable no-shadow */

import assetsSlice, {
  deleteAsset,
  setAssets,
Severity: Minor
Found in client/test/preview/unit/store/Store.test.ts - About 5 hrs to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      it('should call updateFileState if new file is found - create tab', async () => {
        const testFiles: FileState[] = [
          { name: 'file1.md', content: 'content', isNew: true, isModified: false },
        ];
    
    
    client/test/preview/unit/routes/digitaltwins/editor/sidebarFunctions.test.ts on lines 192..214
    client/test/preview/unit/routes/digitaltwins/editor/sidebarFunctions.test.ts on lines 216..238

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 117.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      it('should call updateFileState if new file is found - reconfigure tab', async () => {
        const testFiles: FileState[] = [
          { name: 'file1.md', content: 'content', isNew: false, isModified: true },
        ];
    
    
    client/test/preview/unit/routes/digitaltwins/editor/sidebarFunctions.test.ts on lines 94..116
    client/test/preview/unit/routes/digitaltwins/editor/sidebarFunctions.test.ts on lines 216..238

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 117.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

      it('should call fetchAndSetFileContent if new file is found - reconfigure tab', async () => {
        const testFiles: FileState[] = [
          { name: 'file1.md', content: 'content', isNew: false, isModified: false },
        ];
    
    
    client/test/preview/unit/routes/digitaltwins/editor/sidebarFunctions.test.ts on lines 94..116
    client/test/preview/unit/routes/digitaltwins/editor/sidebarFunctions.test.ts on lines 192..214

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 117.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    const mockGitlabInstance = {
      api: mockApi as unknown as GitlabInstance['api'],
      projectId: 1,
      triggerToken: 'test-token',
      logs: [] as { jobName: string; log: string }[],
    Severity: Major
    Found in client/test/preview/unit/util/digitalTwinConfig.test.ts and 2 other locations - About 3 hrs to fix
    client/test/preview/unit/util/digitalTwin.test.ts on lines 23..30
    client/test/preview/unit/util/fileHandler.test.ts on lines 23..30

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 100.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    const mockGitlabInstance = {
      api: mockApi as unknown as GitlabInstance['api'],
      projectId: 1,
      triggerToken: 'test-token',
      logs: [] as { jobName: string; log: string }[],
    Severity: Major
    Found in client/test/preview/unit/util/digitalTwin.test.ts and 2 other locations - About 3 hrs to fix
    client/test/preview/unit/util/digitalTwinConfig.test.ts on lines 21..28
    client/test/preview/unit/util/fileHandler.test.ts on lines 23..30

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 100.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    const mockGitlabInstance = {
      api: mockApi as unknown as GitlabInstance['api'],
      projectId: 1,
      triggerToken: 'test-token',
      logs: [] as { jobName: string; log: string }[],
    Severity: Major
    Found in client/test/preview/unit/util/fileHandler.test.ts and 2 other locations - About 3 hrs to fix
    client/test/preview/unit/util/digitalTwin.test.ts on lines 23..30
    client/test/preview/unit/util/digitalTwinConfig.test.ts on lines 21..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 100.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File Sidebar.tsx has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as React from 'react';
    import { useEffect, useState, Dispatch, SetStateAction } from 'react';
    import { Grid, CircularProgress, Button, Box } from '@mui/material';
    import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
    import { useDispatch, useSelector } from 'react-redux';
    Severity: Minor
    Found in client/src/preview/route/digitaltwins/editor/Sidebar.tsx - About 2 hrs to fix

      Function handleReconfigureFileClick has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const handleReconfigureFileClick = async (
        fileName: string,
        asset: DigitalTwin | LibraryAsset | null,
        files: FileState[],
        setFileName: Dispatch<SetStateAction<string>>,
      Severity: Major
      Found in client/src/preview/route/digitaltwins/editor/sidebarFunctions.ts - About 2 hrs to fix

        Function AssetLibrary has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function AssetLibrary(props: { pathToAssets: string; privateRepo: boolean }) {
          const assets = useSelector(
            selectAssetsByTypeAndPrivacy(props.pathToAssets, props.privateRepo),
          );
          const [filter, setFilter] = useState('');
        Severity: Major
        Found in client/src/preview/components/asset/AssetLibrary.tsx - About 2 hrs to fix

          Function ShoppingCart has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function ShoppingCart() {
            const { actions } = useCart();
            const navigate = useNavigate();
            const [openDialog, setOpenDialog] = useState(false);
            const dispatch = useDispatch();
          Severity: Major
          Found in client/src/preview/components/cart/ShoppingCart.tsx - About 2 hrs to fix

            File ReconfigureDialog.tsx has 274 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* eslint-disable no-restricted-syntax */
            /* eslint-disable no-await-in-loop */
            
            import * as React from 'react';
            import { useState, Dispatch, SetStateAction } from 'react';
            Severity: Minor
            Found in client/src/preview/route/digitaltwins/manage/ReconfigureDialog.tsx - About 2 hrs to fix

              File AssetCard.tsx has 264 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import * as React from 'react';
              import { useState, Dispatch, SetStateAction } from 'react';
              import Card from '@mui/material/Card';
              import CardContent from '@mui/material/CardContent';
              import Typography from '@mui/material/Typography';
              Severity: Minor
              Found in client/src/preview/components/asset/AssetCard.tsx - About 2 hrs to fix

                File sidebarFunctions.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { addOrUpdateFile, FileState } from 'preview/store/file.slice';
                import DigitalTwin from 'preview/util/digitalTwin';
                import { Dispatch, SetStateAction } from 'react';
                import { useDispatch } from 'react-redux';
                import LibraryAsset from 'preview/util/libraryAsset';
                Severity: Minor
                Found in client/src/preview/route/digitaltwins/editor/sidebarFunctions.ts - About 2 hrs to fix

                  Function SignIn has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function SignIn() {
                    const auth = useAuth();
                  
                    const startAuthProcess = () => {
                      auth.signinRedirect();
                  Severity: Major
                  Found in client/src/route/auth/Signin.tsx - About 2 hrs to fix

                    File sidebarFunctions.test.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import * as SidebarFunctions from 'preview/route/digitaltwins/editor/sidebarFunctions';
                    import { FileState } from 'preview/store/file.slice';
                    import * as FileUtils from 'preview/util/fileUtils';
                    import * as SidebarFetchers from 'preview/route/digitaltwins/editor/sidebarFetchers';
                    import { mockLibraryAsset } from 'test/preview/__mocks__/global_mocks';

                      Function handleCreateFileClick has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const handleCreateFileClick = (
                        fileName: string,
                        asset: DigitalTwin | LibraryAsset | null,
                        files: FileState[],
                        setFileName: Dispatch<SetStateAction<string>>,
                      Severity: Minor
                      Found in client/src/preview/route/digitaltwins/editor/sidebarFunctions.ts - About 1 hr to fix

                        Function handleEditorChange has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const handleEditorChange = (
                          tab: string,
                          value: string | undefined,
                          setEditorValue: Dispatch<SetStateAction<string>>,
                          setFileContent: Dispatch<SetStateAction<string>>,
                        Severity: Minor
                        Found in client/src/preview/route/digitaltwins/editor/EditorTab.tsx - About 1 hr to fix

                          Similar blocks of code found in 5 locations. Consider refactoring.
                          Open

                            it('handles cancel', () => {
                              const cancelButton = screen.getByRole('button', { name: /Cancel/i });
                          
                              act(() => {
                                cancelButton.click();
                          client/test/preview/integration/route/digitaltwins/create/ChangeFileNameDialog.test.tsx on lines 60..67
                          client/test/preview/integration/route/digitaltwins/create/DeleteFileDialog.test.tsx on lines 54..61
                          client/test/preview/integration/route/digitaltwins/create/FileActionButtons.test.tsx on lines 27..34
                          client/test/preview/integration/route/digitaltwins/create/FileActionButtons.test.tsx on lines 36..45

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 71.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 5 locations. Consider refactoring.
                          Open

                            it('handles click on delete button', () => {
                              const deleteButton = screen.getByRole('button', { name: /Delete/i });
                              act(() => {
                                deleteButton.click();
                              });
                          client/test/preview/integration/route/digitaltwins/create/ChangeFileNameDialog.test.tsx on lines 60..67
                          client/test/preview/integration/route/digitaltwins/create/ConfirmDeleteDialog.test.tsx on lines 66..74
                          client/test/preview/integration/route/digitaltwins/create/DeleteFileDialog.test.tsx on lines 54..61
                          client/test/preview/integration/route/digitaltwins/create/FileActionButtons.test.tsx on lines 36..45

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 71.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language