RvanVeenendaal / Spreadsheet-Complexity-Analyser

This software (prototype) extracts values of Excel spreadsheet properties and calculates a tentative spreadsheet complexity assessment based on threshold values.
12 stars 0 forks source link

Unable to use customized config file #21

Open ankoenigs opened 5 months ago

ankoenigs commented 5 months ago

I modified the config file SpreadsheetComplexityAnalyser.cfg and tried executing SCA with the following command:

java -jar SpreadsheetComplexityAnalyser.jar <path-to-DIR> --config SpreadsheetComplexityAnalyser.cfg

I got the following output:

usage: java -jar SpreadsheetComplexityAnalyser.jar DIR [-c] [-h] [-r] [-v]
            [-x]
 -c,--config      config file: read complexity assessment threshold values
                  from SpreadsheetComplexityAnalyser.cfg file
 -h,--help        help: show SpreadsheetComplexityAnalyser help
                  information (and exit)
 -r,--recursive   recurse into subdirectories
 -v,--verbose     verbose output: show number of occurrences of properties
                  in text form
 -x,--xml         xml output: show number of occurrences of properties in
                  xml form (suppresses verbose output)
 DIR              directory with *.xl[st][xm] and *.xl[akms] files to process.
Error: please provide exactly one input DIRectory.

I believe the CLI option was used according to specs, using -c="SpreadsheetComplexityAnalyser.cfg" yields the Error Error: cannot parse command line parameters:Unrecognized option: -c=SpreadsheetComplexityAnalyser.cfg.

I am using the following Java Version:


OpenJDK Runtime Environment (build 11.0.23+9-post-Ubuntu-1ubuntu122.04.1)
OpenJDK 64-Bit Server VM (build 11.0.23+9-post-Ubuntu-1ubuntu122.04.1, mixed mode, sharing)```
RvanVeenendaal commented 5 months ago

Hi @ankoenigs, Thank you for your use of the Spreadsheet Complexity Analyser, and reporting an issue. You don't have to provide the .cfg file name as a command line parameter. Use -c or --config. That is enough: the SCA will look for the config file "SpreadsheetComplexityAnalyser.cfg" in the tool's JAR folder. Note: save versions of your .cfg file under different, versioned mnemonic names.

ankoenigs commented 5 months ago

Thank you for your quick and kind response!
Unfortunately, I still can't excatly get it to work. Now when I use -c without any names specified, I get the following output/error message:

Error: config file not found! Using default values.
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NullPointerException: inStream parameter is null
        at java.base/java.util.Objects.requireNonNull(Objects.java:248)
        at java.base/java.util.Properties.load(Properties.java:409)
        at ApachePOIExcelReader.readConfigFile(ApachePOIExcelReader.java:324)
        at ApachePOIExcelReader.main(ApachePOIExcelReader.java:405)
        ... 5 more

I am confident that the config file has the right name and location, as I downloaded it by cloning this repo and did not change the file name, only the threshold values.

RvanVeenendaal commented 5 months ago

Hi ankoenigs,

This particular error with the InvocationTargetException seems to happen when the SCA can't find/read the cfg. file. If I change the .cfg's file name and use the -c parameter I get this error too. So either your filename was unintentionally changed or the SCA can't find the file.

Or if I start the jar file from somewhere outside it's directory I get the same error.

Fix: explicitly use the jar's folder instead of the folder that the user is in. This probably requires an update of line 404 of ApachePOIExcelReader.java.

For now, please ensure that you start the SCA from the folder where the jar file resides.