INTO-CPS-Association/DTaaS

View on GitHub

Showing 144 of 198 total issues

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

    render(
      <Provider store={store}>
        <ReconfigureDialog
          showDialog={true}
          setShowDialog={jest.fn()}
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 85..93
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 105..113
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 127..135
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 155..163

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

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

    render(
      <Provider store={store}>
        <ReconfigureDialog
          showDialog={true}
          setShowDialog={jest.fn()}
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 69..77
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 105..113
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 127..135
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 155..163

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

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

    render(
      <Provider store={store}>
        <ReconfigureDialog
          showDialog={true}
          setShowDialog={jest.fn()}
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 69..77
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 85..93
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 127..135
client/test/preview/integration/route/digitaltwins/manage/ConfigDialog.test.tsx on lines 155..163

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

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

Function fetchLibraryAssets has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const fetchLibraryAssets = async (
  dispatch: ReturnType<typeof useDispatch>,
  setError: Dispatch<SetStateAction<string | null>>,
  type: string,
  isPrivate: boolean,
Severity: Minor
Found in client/src/preview/util/init.ts - About 1 hr to fix

    Function getFilesFromAsset has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async getFilesFromAsset(assetPath: string, isPrivate: boolean) {
        try {
          const fileNames = await this.fileHandler.getLibraryFileNames(
            assetPath,
            isPrivate,
    Severity: Minor
    Found in client/src/preview/util/DTAssets.ts - About 1 hr to fix

      Function appendTriggerToPipeline has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async appendTriggerToPipeline(): Promise<string> {
          const filePath = `.gitlab-ci.yml`;
      
          try {
            const fileContent = await this.fileHandler.getFileContent(filePath);
      Severity: Minor
      Found in client/src/preview/util/DTAssets.ts - About 1 hr to fix

        Function createCombinedTabs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function createCombinedTabs() {
          return assetType.map((tab) =>
            scope.map((subtab) => ({
              label: `${subtab.label}`,
              body: (
        Severity: Minor
        Found in client/src/preview/route/library/LibraryPreview.tsx - About 1 hr to fix

          Function handleCreateFileClick has a Cognitive Complexity of 10 (exceeds 5 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

          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 CardActionAreaContainer has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function CardActionAreaContainer(asset: Asset, library?: boolean) {
            const digitalTwin = useSelector(
              (state: RootState) => state.digitalTwin.digitalTwin[asset.name],
            );
          
          
          Severity: Minor
          Found in client/src/preview/components/asset/AssetCard.tsx - About 1 hr to fix

            Function create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async create(
                files: FileState[],
                cartAssets: LibraryAsset[],
                libraryFiles: LibraryConfigFile[],
              ): Promise<string> {
            Severity: Minor
            Found in client/src/preview/util/digitalTwin.ts - About 1 hr to fix

              Function prepareAllAssetFiles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async prepareAllAssetFiles(
                  cartAssets: LibraryAsset[],
                  libraryFiles: LibraryConfigFile[],
                ): Promise<
                  Array<{
              Severity: Minor
              Found in client/src/preview/util/digitalTwin.ts - About 1 hr to fix

                Function handleFileUpdate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const handleFileUpdate = async (
                  file: FileState | LibraryConfigFile,
                  digitalTwin: DigitalTwin,
                  dispatch: ReturnType<typeof useDispatch>,
                ) => {
                Severity: Minor
                Found in client/src/preview/route/digitaltwins/manage/ReconfigureDialog.tsx - About 1 hr to fix

                  Function DTContent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const DTContent = () => {
                    const [newDigitalTwinName, setNewDigitalTwinName] = React.useState('');
                    const dispatch = useDispatch();
                  
                    useEffect(() => {
                  Severity: Minor
                  Found in client/src/preview/route/digitaltwins/DigitalTwinsPreview.tsx - About 1 hr to fix

                    Function addOrUpdateLibraryFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        addOrUpdateLibraryFile: (
                          state,
                          action: PayloadAction<LibraryConfigFile>,
                        ) => {
                          const { fileName, assetPath, isNew, isPrivate, ...rest } = action.payload;
                    Severity: Minor
                    Found in client/src/preview/store/libraryConfigFiles.slice.ts - About 1 hr to fix

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

                          const files = [
                            { name: 'file1', content: 'content', isNew: true, isModified: false },
                            { name: 'file2', content: 'content', isNew: true, isModified: false },
                          ];
                      Severity: Major
                      Found in client/test/preview/unit/util/fileUtils.test.ts and 2 other locations - About 50 mins to fix
                      client/test/preview/unit/util/fileUtils.test.ts on lines 8..11
                      client/test/preview/unit/util/fileUtils.test.ts on lines 28..31

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

                      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 files = [
                            { name: 'file1', content: '', isNew: true, isModified: false },
                            { name: 'file2', content: 'content', isNew: true, isModified: false },
                          ];
                      Severity: Major
                      Found in client/test/preview/unit/util/fileUtils.test.ts and 2 other locations - About 50 mins to fix
                      client/test/preview/unit/util/fileUtils.test.ts on lines 28..31
                      client/test/preview/unit/util/fileUtils.test.ts on lines 123..126

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

                      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 files = [
                            { name: 'file1', content: 'content', isNew: true, isModified: false },
                            { name: 'file2', content: 'content', isNew: true, isModified: false },
                          ];
                      Severity: Major
                      Found in client/test/preview/unit/util/fileUtils.test.ts and 2 other locations - About 50 mins to fix
                      client/test/preview/unit/util/fileUtils.test.ts on lines 8..11
                      client/test/preview/unit/util/fileUtils.test.ts on lines 123..126

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

                      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

                      jest.mock('react-redux', () => ({
                        ...jest.requireActual('react-redux'),
                        useSelector: jest.fn(),
                        useDispatch: jest.fn(),
                      }));
                      client/test/preview/__mocks__/unit/module_mocks.ts on lines 1..5
                      client/test/preview/unit/routes/digitaltwins/create/CreateDTDialog.test.tsx on lines 11..15

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

                      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

                      jest.mock('react-redux', () => ({
                        ...jest.requireActual('react-redux'),
                        useDispatch: jest.fn(),
                        useSelector: jest.fn(),
                      }));
                      Severity: Major
                      Found in client/test/preview/__mocks__/unit/module_mocks.ts and 2 other locations - About 50 mins to fix
                      client/test/preview/unit/routes/digitaltwins/create/ConfirmDeleteDialog.test.tsx on lines 11..15
                      client/test/preview/unit/routes/digitaltwins/create/CreateDTDialog.test.tsx on lines 11..15

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

                      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

                      jest.mock('react-redux', () => ({
                        ...jest.requireActual('react-redux'),
                        useSelector: jest.fn(),
                        useDispatch: jest.fn(),
                      }));
                      client/test/preview/__mocks__/unit/module_mocks.ts on lines 1..5
                      client/test/preview/unit/routes/digitaltwins/create/ConfirmDeleteDialog.test.tsx on lines 11..15

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

                      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