nihas101/java-kotlin-images-to-pdf-converter

View on GitHub

Showing 32 of 32 total issues

File MainWindowController.java has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 JaKoImage2PDF is a program for converting images to PDFs with the use of iText 7
 Copyright (C) 2018  Nikita Hasert

 This program is free software: you can redistribute it and/or modify

    MainWindowController has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class MainWindowController extends FileListViewController {
        @FXML
        public Button directoryButton;
        @FXML
        public Button buildButton;

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

      class IteratorSetupProgressUpdater(mainWindowController: MainWindowController) : FileProgressUpdater(mainWindowController) {
          private val logger = LoggerFactory.getLogger(IteratorSetupProgressUpdater::class.java)!!
      
          override fun updateProgress(progress: Double, file: File) {
              super.updateProgress(progress, "Processing file(s):  ${file.name}")
      src/main/kotlin/de/nihas101/image_to_pdf_converter/util/ProgressUpdater.kt on lines 70..77

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

      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 2 locations. Consider refactoring.
      Open

      class BuildProgressUpdater(mainWindowController: MainWindowController) : FileProgressUpdater(mainWindowController) {
          private val logger = LoggerFactory.getLogger(BuildProgressUpdater::class.java)!!
      
          override fun updateProgress(progress: Double, file: File) {
              super.updateProgress(progress, "Building PDF:  ${file.name}")
      src/main/kotlin/de/nihas101/image_to_pdf_converter/util/ProgressUpdater.kt on lines 79..86

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

      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 2 locations. Consider refactoring.
      Open

          private fun processFile(file: File): List<File> {
              val processedFiles = mutableListOf<File>()
      
              if (canUnzip(file)) processedFiles.addAll(tryToUnzip(file))
              else if (isImage(file)) processedFiles.add(file)
      src/main/kotlin/de/nihas101/image_to_pdf_converter/directory_iterators/image_iterators/ImageDirectoriesIterator.kt on lines 85..92

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

      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 2 locations. Consider refactoring.
      Open

          private fun processFile(file: File): MutableList<File> {
              val processedFiles = mutableListOf<File>()
      
              if (canUnzip(file)) processedFiles.addAll(tryToUnzip(file))
              else if (isImageDirectory(file)) processedFiles.add(file)
      src/main/kotlin/de/nihas101/image_to_pdf_converter/directory_iterators/image_iterators/ImageFilesIterator.kt on lines 84..91

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              filesToAdd.forEachIndexed { index, file ->
                  processedFiles.addAll(processFile(file))
                  progressUpdater.updateProgress((index + 1).toDouble() / outOf.toDouble(), file)
              }
      src/main/kotlin/de/nihas101/image_to_pdf_converter/directory_iterators/image_iterators/ImageDirectoriesIterator.kt on lines 77..80

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

      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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              filesToAdd.forEachIndexed { index, file ->
                  processedFiles.addAll(processFile(file))
                  progressUpdater.updateProgress((index + 1).toDouble() / outOf.toDouble(), file)
              }
      src/main/kotlin/de/nihas101/image_to_pdf_converter/directory_iterators/image_iterators/ImageFilesIterator.kt on lines 75..78

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

      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

      Method buildPDF has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void buildPDF(ActionEvent actionEvent) {
              File saveFile = mainWindowController.mainWindow.openSaveFileChooser(
                      directoryIterator.getParentDirectory(),
                      directoryIterator.getParentDirectory().getName() + ".pdf"
              );

        Method build has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            override fun build(directoryIterator: DirectoryIterator, imageToPdfOptions: ImageToPdfOptions, progressUpdater: ProgressUpdater): Boolean {
                directoryIterator.resetIndex()
        
                val imagePdf = if (imageToPdfOptions.getPdfOptions().useCustomLocation) createPdf(imageToPdfOptions)
                else createPdf(

          Method displayDirectory has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private void displayDirectory(int index, MainWindowController mainWindowController) {
                  DirectoryIterator imageFilesIterator = DirectoryIterator.DirectoryIteratorFactory.createDirectoryIterator(
                          new IteratorOptions()
                  );
          
          

            Method setupImageListCellContextMenu has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private fun setupImageListCellContextMenu(file: File) {
                    contextMenu = ContextMenu()
                    contextMenu.id = "listCellContextMenu"
            
                    val deleteItem = setupMenuItem(

              Method startPdfBuilderThread has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void startPdfBuilderThread(PdfBuilder pdfBuilder) {
                      CallClosure callClosure = new CallClosure(
                              () -> {
                                  runLater(() -> disableInput(true));
                                  return Unit.INSTANCE;

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

                        fun createSetupIteratorTask(
                                directoryIterator: DirectoryIterator,
                                directory: File,
                                progressUpdater: ProgressUpdater,
                                callClosure: CallClosure
                src/main/kotlin/de/nihas101/image_to_pdf_converter/tasks/SetupIteratorTask.kt on lines 49..61

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

                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 2 locations. Consider refactoring.
                Open

                        fun createSetupIteratorTask(
                                directoryIterator: DirectoryIterator,
                                file: File,
                                progressUpdater: ProgressUpdater,
                                callClosure: CallClosure
                src/main/kotlin/de/nihas101/image_to_pdf_converter/tasks/SetupIteratorFromDragAndDropTask.kt on lines 33..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 91.

                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 2 locations. Consider refactoring.
                Open

                        fun createIteratorMoveModification(modificationArguments: List<String>): IteratorMoveAction {
                            if (isFormedCorrectly(modificationArguments)) return IteratorMoveAction(modificationArguments)
                            else throw MalformedPdfActionException(modificationArguments)
                        }
                src/main/kotlin/de/nihas101/image_to_pdf_converter/directory_iterators/iterator_action/IteratorRemoveAction.kt on lines 35..38

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

                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 2 locations. Consider refactoring.
                Open

                        fun createIteratorRemoveModification(modificationArguments: List<String>): IteratorRemoveAction {
                            if (isFormedCorrectly(modificationArguments)) return IteratorRemoveAction(modificationArguments)
                            else throw MalformedPdfActionException(modificationArguments)
                        }
                src/main/kotlin/de/nihas101/image_to_pdf_converter/directory_iterators/iterator_action/IteratorMoveAction.kt on lines 36..39

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

                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

                Method pdfVersionToIndex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private int pdfVersionToIndex(PdfVersion pdfVersion) {
                        if (pdfVersion.equals(PDF_1_0)) return 0;
                        else if (pdfVersion.equals(PDF_1_1)) return 1;
                        else if (pdfVersion.equals(PDF_1_2)) return 2;
                        else if (pdfVersion.equals(PDF_1_3)) return 3;

                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

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

                    fun setMultipleDirectories(multipleDirectories: Boolean) {
                        logger.info("Set multiple directories to {}", multipleDirectories)
                        iteratorOptions = iteratorOptions.copy(multipleDirectories = multipleDirectories)
                    }
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 46..49
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 51..54
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 61..64
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 66..69

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

                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

                    fun setDeleteOnExit(deleteOnExit: Boolean) {
                        logger.info("Set delete on exit to {}", deleteOnExit)
                        iteratorOptions = iteratorOptions.copy(deleteOnExit = deleteOnExit)
                    }
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 41..44
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 46..49
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 61..64
                src/main/kotlin/de/nihas101/image_to_pdf_converter/pdf/pdf_options/ImageToPdfOptions.kt on lines 66..69

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

                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