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

View on GitHub

Showing 15 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;

      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;

                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

                Method createBuildPdfTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                                pdfBuilder: PdfBuilder,
                                directoryIterator: DirectoryIterator,
                                imageToPdfOptions: ImageToPdfOptions,
                                progressUpdater: ProgressUpdater,
                                callClosure: CallClosure
                Severity: Minor
                Found in src/main/kotlin/de/nihas101/image_to_pdf_converter/tasks/BuildPdfTask.kt - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          if (pdfVersion.equals(PDF_1_0)) return 0;

                    Avoid too many return statements within this method.
                    Open

                            else if (pdfVersion.equals(PDF_1_4)) return 4;

                      Avoid too many return statements within this method.
                      Open

                              else if (pdfVersion.equals(PDF_1_2)) return 2;

                        Avoid too many return statements within this method.
                        Open

                                else if (pdfVersion.equals(PDF_1_3)) return 3;

                          Avoid too many return statements within this method.
                          Open

                                  else if (pdfVersion.equals(PDF_1_1)) return 1;

                            Method buildPdf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public void buildPdf(ActionEvent actionEvent) {
                                    if (!valuesSetForBuilding()) return;
                            
                                    if (mainWindow.imageToPdfOptions.getPdfOptions().getUseCustomLocation()) {
                                        if (userWantsMultiplePDFs()) buildMultiplePdf();

                            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