Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some SonarCloud issues from the complete code analysis #49

Merged
merged 53 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
cd537d6
Fixed some SonarCloud issues;
JonasSchaub Mar 4, 2024
37f3ea7
Fixed string concatenation, cannot do anything about duplications now;
JonasSchaub Mar 4, 2024
59c1836
Same as before;
JonasSchaub Mar 4, 2024
df0fda7
Fixed SonarCloud complaints;
JonasSchaub Mar 4, 2024
bea1219
introduced a configuration properties file and changed a few things a…
JonasSchaub Mar 5, 2024
ef17d27
Fixed import of resource files via configurations class, also works f…
JonasSchaub Mar 6, 2024
8910e4e
All resource files are imported via paths and file names in configura…
JonasSchaub Mar 6, 2024
73111a1
Removed unused imports;
JonasSchaub Mar 6, 2024
d3d0f7f
No more exceptions when a configurations instance is passed as param …
JonasSchaub Mar 6, 2024
202c390
Moved some folder names from BasicDefinitions to Configuration
JonasSchaub Mar 6, 2024
71d9a78
Removed unused param according to https://github.com/FelixBaensch/MOR…
JonasSchaub Mar 7, 2024
0ba77f2
Made sure all buttons have the same sizes;
JonasSchaub Mar 7, 2024
6203b4c
Defined general font size;
JonasSchaub Mar 7, 2024
5843c12
Merge branch 'production' into sonar-issues-fix
JonasSchaub Mar 11, 2024
51a1379
Abbreviated export button labels and exchanged histogram button label…
JonasSchaub Mar 11, 2024
26d9b3d
Renamed and restructured method to get items of active tab;
JonasSchaub Mar 11, 2024
62548b5
Encapsulated the custom pagination with suitable page count creation …
JonasSchaub Mar 11, 2024
2c29323
Separated overview view setting for first structure highlight and jum…
JonasSchaub Mar 11, 2024
e5638b8
Mainly merged some if statements;
JonasSchaub Mar 11, 2024
39ecbc7
More SonarCloud issues fixes, i.a. throwing specific exceptions in Vi…
JonasSchaub Mar 12, 2024
a2dc5fd
Reversed exchanging [0-9] by \d in regex patterns for better readabil…
JonasSchaub Mar 13, 2024
0c911c6
SimpleEnumConstantnamePropertyTest overhaul, added assertions, remove…
JonasSchaub Mar 13, 2024
8f3702a
Added check for successful initialization of Configuration to MainApp…
JonasSchaub Mar 13, 2024
4590260
Refer to interfaces instead of specific class for HashMap in Molecule…
JonasSchaub Mar 13, 2024
dd2f0a3
Fixed bug that items tab was not sortable by name (unmodifiable list …
JonasSchaub Mar 14, 2024
89094bc
Documenting and linting; refactored depictBufferedImageWithZoom method;
JonasSchaub Mar 14, 2024
52f0d09
Linting and fixing some sonar issues in FragmentationService mostly; …
JonasSchaub Mar 14, 2024
5ca25e7
Fixing sonar complaints and linting in FragmentationTask and all frag…
JonasSchaub Mar 15, 2024
04961c0
Fix EFGF instance instantiated too late in the constructor;
JonasSchaub Mar 15, 2024
6eaba95
Overhaul of exporter, mostly exception treatment (more is passed on t…
JonasSchaub Mar 18, 2024
bdc12be
Fixed bug in items tab PDF export, number of fragments in header was …
JonasSchaub Mar 19, 2024
3224b7c
A few changes and additions in headers of exported files;
JonasSchaub Mar 19, 2024
a45bb63
Fix spotless complaint;
JonasSchaub Mar 19, 2024
c0fc480
Changed CSV export separator char from being set directly to an enum …
JonasSchaub Mar 19, 2024
b944857
Overhaul of importer;
JonasSchaub Mar 19, 2024
9b61c2d
Overhaul of SettingsContainer;
JonasSchaub Mar 19, 2024
9daa33f
Replacing some string concatenations with string.format calls;
JonasSchaub Mar 19, 2024
7ae13f9
Overhaul of some util classes;
JonasSchaub Mar 19, 2024
493d861
Introduced separate display names for settings (general and for fragm…
JonasSchaub Mar 20, 2024
c18817e
Defined fixed size for combo boxes in the settings views;
JonasSchaub Mar 20, 2024
4af7a03
Started working on a new custom property to wrap the language-specifi…
JonasSchaub Mar 20, 2024
d8f1847
Added SimpleIDisplayEnumConstantProperty as new JavaFX property that …
JonasSchaub Mar 21, 2024
e494708
Replaced all SimpleEnumConstantNameProperty settings with SimpleIDisp…
JonasSchaub Mar 22, 2024
9a3d613
Updated spotless; moved openFilePathInExplorer() to FileUtil; overhau…
JonasSchaub Mar 25, 2024
11c812d
make constructors protected;
JonasSchaub Mar 25, 2024
2efc444
Final clean-up, mostly linting; added a MORTARException class but end…
JonasSchaub Mar 26, 2024
2e8f5e3
Trying to reduce duplications;
JonasSchaub Mar 26, 2024
ef799ef
Final clean-up, mostly linting; fixed possible eternal loop in Prefer…
JonasSchaub Mar 27, 2024
09047af
Reduced duplication by moving translation of preferences to propertie…
JonasSchaub Mar 27, 2024
7f42944
Added separate display name to fragmenters but not used yet; added no…
JonasSchaub Mar 28, 2024
26a7a3c
Changed integer filter of settings view integer text fields to positi…
JonasSchaub Mar 28, 2024
481184a
Changed double filter of settings view double text fields to positive…
JonasSchaub Mar 28, 2024
095a146
Separated usage of algorithm name for internal use and algorithm disp…
JonasSchaub Apr 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ private void openGlobalSettingsView() {
((GridTabForTableView) tmpTab).getPagination().setPageCount(tmpPageCount);
((GridTabForTableView) tmpTab).getPagination().setCurrentPageIndex(tmpPageIndex);
((GridTabForTableView) tmpTab).getTableView().refresh();
GuiUtil.setImageStructureHeight(((GridTabForTableView) tmpTab).getTableView(), ((GridTabForTableView) tmpTab).getTableView().getHeight(), this.settingsContainer);
GuiUtil.setImageStructureHeight(((GridTabForTableView) tmpTab).getTableView(), ((GridTabForTableView) tmpTab).getTableView().getHeight(), this.settingsContainer.getRowsPerPageSetting());
((GridTabForTableView) tmpTab).getTableView().refresh();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ hold the pagination node (since the structureGridPane and pagination node size a
//check if the limits for the image dimensions are being exceeded
if ((tmpImageHeight >= OverviewViewController.OVERVIEW_VIEW_STRUCTURE_IMAGE_MIN_HEIGHT)
&& (tmpImageWidth >= OverviewViewController.OVERVIEW_VIEW_STRUCTURE_IMAGE_MIN_WIDTH)) {
//optional setting for change in usage of shadow effect
//optional setting for change in usage of shadow effect - deprecated
boolean tmpDrawImagesWithShadow = true;
//main loop for generation of the page content
generationOfStructureImagesLoop:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public ViewToolsManager(IConfiguration aConfiguration) {
this.viewToolsArray[1] = this.overviewViewController;
try {
this.checkViewTools();
} catch (Exception anException) {
} catch (IOException anException) {
ViewToolsManager.LOGGER.log(Level.SEVERE, anException.toString(), anException);
GuiUtil.guiExceptionAlert(Message.get("Error.ExceptionAlert.Title"),
Message.get("Error.ExceptionAlert.Header"),
Expand Down Expand Up @@ -210,13 +210,14 @@ public void persistViewToolsSettings() {
PreferenceContainer tmpPrefContainer = PreferenceUtil.translateJavaFxPropertiesToPreferences(tmpSettings, tmpFilePath);
tmpPrefContainer.writeRepresentation();
} catch (NullPointerException | IllegalArgumentException | IOException | SecurityException anException) {
ViewToolsManager.LOGGER.log(Level.WARNING, "View tools settings persistence went wrong, exception: "
+ anException.toString(), anException);
ViewToolsManager.LOGGER.log(Level.WARNING,
String.format("View tools settings persistence went wrong, exception: %s", anException.toString()),
anException);
GuiUtil.guiExceptionAlert(Message.get("Error.ExceptionAlert.Title"),
Message.get("Error.ExceptionAlert.Header"),
Message.get("ViewToolsManager.Error.settingsPersistence"),
anException);
continue;
//continue;
}
}
}
Expand All @@ -236,14 +237,15 @@ public void reloadViewToolsSettings() {
try {
tmpContainer = new PreferenceContainer(tmpViewToolsSettingsFile);
} catch (IllegalArgumentException | IOException anException) {
ViewToolsManager.LOGGER.log(Level.WARNING, "Unable to reload settings of view tool "
+ tmpClassName + " : " + anException.toString(), anException);
ViewToolsManager.LOGGER.log(Level.WARNING,
String.format("Unable to reload settings of view tool %s: %s", tmpClassName, anException.toString()),
anException);
continue;
}
this.updatePropertiesFromPreferences(tmpViewTool.settingsProperties(), tmpContainer);
} else {
//settings will remain in default
ViewToolsManager.LOGGER.log(Level.WARNING, "No persisted settings for " + tmpClassName + " available.");
ViewToolsManager.LOGGER.log(Level.WARNING, "No persisted settings for {0} available.", tmpClassName);
}
}
}
Expand Down Expand Up @@ -274,32 +276,32 @@ private void updatePropertiesFromPreferences(List<Property> aPropertiesList, Pre
tmpSettingProperty.setValue(tmpStringPreference.getContent());
} else {
//setting will remain in default
ViewToolsManager.LOGGER.log(Level.WARNING, "Setting " + tmpPropertyName + " is of unknown type.");
ViewToolsManager.LOGGER.log(Level.WARNING, "Setting {0} is of unknown type.", tmpPropertyName);
}
} catch (ClassCastException | IllegalArgumentException anException) {
//setting will remain in default
ViewToolsManager.LOGGER.log(Level.WARNING, anException.toString(), anException);
}
} else {
//setting will remain in default
ViewToolsManager.LOGGER.log(Level.WARNING, "No persisted settings for " + tmpPropertyName + " available.");
ViewToolsManager.LOGGER.log(Level.WARNING, "No persisted settings for {0} available.", tmpPropertyName);
}
}
}
/**
* Checks the available view tools and their settings for restrictions imposed by persistence. Throws an exception if
* Checks the available view tools and their settings for restrictions imposed by persistence. Throws an IOException if
* anything does not meet the requirements.
*/
private void checkViewTools() throws Exception {
private void checkViewTools() throws IOException {
HashSet<String> tmpViewToolNames = new HashSet<>((int)(this.viewToolsArray.length * 1.5), 0.75f);
for (IViewToolController tmpViewTool : this.viewToolsArray) {
//view tool name should be singleton and must be persistable
String tmpViewToolName = tmpViewTool.getViewToolNameForDisplay();
if (!PreferenceUtil.isValidName(tmpViewToolName) || !SingleTermPreference.isValidContent(tmpViewToolName)) {
throw new Exception("View tool name " + tmpViewToolName + " is invalid.");
throw new IOException(String.format("View tool name %s is invalid.", tmpViewToolName));
}
if (tmpViewToolNames.contains(tmpViewToolName)) {
throw new Exception("View tool name " + tmpViewToolName + " is used multiple times.");
throw new IOException(String.format("View tool name %s is used multiple times.", tmpViewToolName));
} else {
tmpViewToolNames.add(tmpViewToolName);
}
Expand All @@ -310,29 +312,29 @@ private void checkViewTools() throws Exception {
HashSet<String> tmpSettingNames = new HashSet<>((int) (tmpSettingsList.size() * 1.5), 0.75f);
for (Property tmpSetting : tmpSettingsList) {
if (!PreferenceUtil.isValidName(tmpSetting.getName())) {
throw new Exception("Setting " + tmpSetting.getName() + " has an invalid name.");
throw new IOException(String.format("Setting %s has an invalid name.", tmpSetting.getName()));
}
if (tmpSettingNames.contains(tmpSetting.getName())) {
throw new Exception("Setting name " + tmpSetting.getName() + " is used multiple times.");
throw new IOException(String.format("Setting name %s is used multiple times.", tmpSetting.getName()));
} else {
tmpSettingNames.add(tmpSetting.getName());
}
if (tmpSetting instanceof SimpleBooleanProperty) {
//nothing to do here, booleans cannot have invalid values
} else if (tmpSetting instanceof SimpleIntegerProperty) {
if (!SingleIntegerPreference.isValidContent(Integer.toString(((SimpleIntegerProperty) tmpSetting).get()))) {
throw new Exception("Setting value " + ((SimpleIntegerProperty) tmpSetting).get() + " of setting name " + tmpSetting.getName() + " is invalid.");
throw new IOException(String.format("Setting value %d of setting name %s is invalid.", ((SimpleIntegerProperty) tmpSetting).get(), tmpSetting.getName()));
}
} else if (tmpSetting instanceof SimpleDoubleProperty) {
if (!SingleNumberPreference.isValidContent(((SimpleDoubleProperty) tmpSetting).get())) {
throw new Exception("Setting value " + ((SimpleDoubleProperty) tmpSetting).get() + " of setting name " + tmpSetting.getName() + " is invalid.");
throw new IOException(String.format("Setting value %d of setting name %s is invalid.", ((SimpleDoubleProperty) tmpSetting).get(), tmpSetting.getName()));
}
} else if (tmpSetting instanceof SimpleEnumConstantNameProperty || tmpSetting instanceof SimpleStringProperty) {
if (!SingleTermPreference.isValidContent(((SimpleStringProperty) tmpSetting).get())) {
throw new Exception("Setting value " + ((SimpleStringProperty) tmpSetting).get() + " of setting name " + tmpSetting.getName() + " is invalid.");
throw new IOException(String.format("Setting value %s of setting name %s is invalid.", ((SimpleStringProperty) tmpSetting).get(), tmpSetting.getName()));
}
} else {
throw new Exception("Setting " + tmpSetting.getName() + " is of an invalid type.");
throw new IOException(String.format("Setting %s is of an invalid type.", tmpSetting.getName()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,123 +41,121 @@
* @version 1.0.0.0
*/
public class MainMenuBar extends MenuBar {

//<editor-fold desc="private class variables" defaultstate="collapsed">
//<editor-fold desc="private final class constants" defaultstate="collapsed">
/**
* FileMenu
*/
private Menu fileMenu;
private final Menu fileMenu;
/**
* MenuItem to import molecules
*/
private MenuItem openMenuItem;
private final MenuItem openMenuItem;
/**
* MenuItem for export
*/
private Menu exportMenu;
private final Menu exportMenu;
/**
* Menu for fragments export
*/
private Menu fragmentsExportMenu;
private final Menu fragmentsExportMenu;
/**
* MenuItem to export fragments as csv file
*/
private MenuItem fragmentsExportToCSVMenuItem;
private final MenuItem fragmentsExportToCSVMenuItem;
/**
* MenuItem to export fragments as pdb file
*/
private MenuItem fragmentsExportToPDBMenuItem;
private final MenuItem fragmentsExportToPDBMenuItem;
/**
* MenuItem to export fragments as pdf file
*/
private MenuItem fragmentsExportToPDFMenuItem;
private final MenuItem fragmentsExportToPDFMenuItem;
/**
* Menu for fragments export as sdf
*/
private Menu fragmentsExportToSDFMenu;
private final Menu fragmentsExportToSDFMenu;
/**
* MenuItem to export fragments as sd file
*/
private MenuItem fragmentsExportToSingleSDFMenuItem;
private final MenuItem fragmentsExportToSingleSDFMenuItem;
/**
* MenuItem to export fragments as sd file separately
*/
private MenuItem fragmentsExportToSeparateSDFsMenuItem;
private final MenuItem fragmentsExportToSeparateSDFsMenuItem;
/**
* Menu for items export
*/
private Menu itemsExportMenu;
private final Menu itemsExportMenu;
/**
* MenuItem to export items as csv file
*/
private MenuItem itemsExportToCSVMenuItem;
private final MenuItem itemsExportToCSVMenuItem;
/**
* MenuItem to export fragments as pdf file
*/
private MenuItem itemsExportToPDFMenuItem;
private final MenuItem itemsExportToPDFMenuItem;
/**
* MenuItem to exit app
*/
private MenuItem exitMenuItem;
private final MenuItem exitMenuItem;
/**
* Menu for settings
*/
private Menu settingsMenu;
private final Menu settingsMenu;
/**
* Menu for pipeline
*/
private Menu pipelineMenu;
private final Menu pipelineMenu;
/**
* Menu for help
*/
private Menu helpMenu;
private final Menu helpMenu;
/**
* MenuItem to open fragmentation settings
*/
private MenuItem fragmentationSettingsMenuItem;
private final MenuItem fragmentationSettingsMenuItem;
/**
* MenuItem to open global settings
*/
private MenuItem globalSettingsMenuItem;
private final MenuItem globalSettingsMenuItem;
/**
* MenuItem to open pipeline settings
*/
private MenuItem pipelineSettingsMenuItem;
private final MenuItem pipelineSettingsMenuItem;
/**
* MenuItem to open AboutView
*/
private MenuItem aboutViewMenuItem;
private final MenuItem aboutViewMenuItem;
/**
* Menu to choose fragmentation algorithm
*/
private Menu fragmentationAlgorithmMenu;
private final Menu fragmentationAlgorithmMenu;
/**
* MenuItem to cancel molecule import, only visible if import is running
*/
private MenuItem cancelImportMenuItem;
private final MenuItem cancelImportMenuItem;
/**
* MenuItem to cancel export, only visible if import is running
*/
private MenuItem cancelExportMenuItem;
private final MenuItem cancelExportMenuItem;
/**
* Menu to open views
*/
private Menu viewsMenu;
private final Menu viewsMenu;
/**
* MenuItem to open the histogram
*/
private MenuItem histogramViewerMenuItem;
private final MenuItem histogramViewerMenuItem;
/**
* MenuItem to open the OverviewView
*/
private MenuItem overviewViewMenuItem;
private final MenuItem overviewViewMenuItem;
//</editor-fold>
//
//<editor-fold desc="constructor" defaultstate="collapsed">
/**
* Constructor
* It initialises the MainMenuBar's components, adds them to the MainMenuBar.
* No listeners were added here.
* Initialises the MainMenuBar's components and adds them to the MainMenuBar.
* No listeners are added here.
*/
public MainMenuBar(){
super();
Expand Down Expand Up @@ -275,7 +273,6 @@ private void addComponentsToExportMenu(){
this.fragmentsExportMenu.getItems().add(this.fragmentsExportToSDFMenu);
this.fragmentsExportToSDFMenu.getItems().add(this.fragmentsExportToSingleSDFMenuItem);
this.fragmentsExportToSDFMenu.getItems().add(this.fragmentsExportToSeparateSDFsMenuItem);
// this.exportMenu.show();
//</editor-fold>
//<editor-fold desc="itemsExportMenu" defaultstate="collapsed">
this.exportMenu.getItems().add(this.itemsExportMenu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,19 @@
* @version 1.0.0.0
*/
public class StatusBar extends FlowPane {

//<editor-fold desc="private class variables" defaultstate="collapsed">
//<editor-fold desc="private final class constants" defaultstate="collapsed">
/**
* Label to show status message
*/
private Label statusLabel;
private final Label statusLabel;
/**
* ProgressBar
*/
private ProgressBar progressBar;
private final ProgressBar progressBar;
//</editor-fold>
//
/**
* Constructor
* Constructor.
*/
public StatusBar(){
super();
Expand All @@ -73,15 +72,15 @@ public StatusBar(){
//
//<editor-fold desc="properties" defaultstate="collapsed">
/**
* Returns statusLabel
* Returns statusLabel.
* @return Label
*/
public Label getStatusLabel() {
return this.statusLabel;
}
//
/**
* Returns the progressBar
* Returns the progressBar.
* @return ProgressBar
*/
public ProgressBar getProgressBar() {
Expand Down
Loading
Loading