diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index b651bc9..9f992d0 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -3,8 +3,6 @@ name: Running Gradle jobs on: push: branches: [] - pull_request: - branches: [] jobs: testing: diff --git a/.idea/misc.xml b/.idea/misc.xml index 87a20fc..41f8dd1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index 1f1ac18..d33c6fa 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,62 @@ Do you have a problem with duplicated functions in your java project? Here is the solution on how to find all the duplicate functions, specify the location of your repository in the local-config.properties file (just make a copy of config.properties) and run the code! Then you will get a file in "results" with all the places where functions match. ### There are even some extra features such as ### + * query an LLM on complicated situations where 2 functions could be similar * lots of configuration * it even has testing for it! ----------------- -### *Please set up before committing* ### -This will run tests when committing and pushing. +## Testing ## + +### Manually ### + +To run the tests run this command: + +```bash +./gradlew test +``` + +### Setting up pre-commit testing ### -To skip the testing you can use the `-n` or `--no-verify` when committing. +If you want the tests to run when you commit code (to be sure it's working), you can install this hook locally. -``` bash +To skip using it once, use `-n` or `--no-verify` when committing. +E.g. `git commit -nm "[commit message]"` + +#### Install Hook #### + +```bash cp pre-commit.tests .git/hooks/pre-commit -cp pre-commit.tests .git/hooks/pre-push -chmod u+x gradlew \ - .git/hooks/pre-commit \ - .git/hooks/pre-push -``` \ No newline at end of file +chmod u+x .git/hooks/pre-commit +``` + +#### Uninstall Hook #### + +```bash +rm .git/hooks/pre-commit +``` + +## Getting started with the large language model (LLM) ## + +### Download the language model (follow one of these instructions) ### +Download the bin-file directly from [Hugging Face](https://huggingface.co/): +[ggml-model-gpt4all-falcon-q4_0.bin](https://huggingface.co/nomic-ai/gpt4all-falcon-ggml/resolve/main/ggml-model-gpt4all-falcon-q4_0.bin?download=true) (4.06 GB) + +Choose downloads from the website: +[https://huggingface.co/nomic-ai/gpt4all-falcon-ggml/tree/main](https://huggingface.co/nomic-ai/gpt4all-falcon-ggml/tree/main) + +You may also download any other model of your taste and use that one instead. + +### Set up the configuration ### + +#### Add model and set the configuration to use LLM #### + +1. Move the downloaded LLM into a new folder called `model` in the main repository. +2. In `config.properties`, set `LLM_FILE` to the name of your downloaded model (e.g. model/ggml-model-gpt4all-falcon-q4_0.bin). +3. In `config.properties`, set `RUN_WITH_LLM` to `true`. + +#### Usage #### +Run `Main.java` in the project. + +#### Results #### +The results will be shown in the `/results/` folder, diff --git a/src/main/java/CodeCheck/ConfigInterface.java b/src/main/java/CodeCheck/ConfigInterface.java index 451e82e..f0596a7 100644 --- a/src/main/java/CodeCheck/ConfigInterface.java +++ b/src/main/java/CodeCheck/ConfigInterface.java @@ -44,23 +44,22 @@ public Config() {} public void loadConfig() throws IOException { this.appProps = new Properties(); - String rootDirRegex = "(.*Code-check/).*"; - String rootPath = FileSystems.getDefault().getPath("").toAbsolutePath().toString() + File.separator; + String rootDirPath = FileSystems.getDefault().getPath("").toAbsolutePath().toString() + File.separator; + String appConfigPath = rootDirPath + "config.properties"; + File test_conf = new File(rootDirPath + "test-config.properties"); - String appConfigPath = rootPath + "config.properties"; - File test_conf = new File(rootPath + "test-config.properties"); if (test_conf.exists() && countLines(test_conf) > 1) { - appConfigPath = rootPath + "test-config.properties"; + appConfigPath = rootDirPath + "test-config.properties"; - } else if (new File(rootPath + "local-config.properties").exists()) { - appConfigPath = rootPath + "local-config.properties"; + } else if (new File(rootDirPath + "local-config.properties").exists()) { + appConfigPath = rootDirPath + "local-config.properties"; } try { appProps.load(new FileInputStream(appConfigPath)); } catch (Exception e) { throw new NullPointerException("Could not find any matching expression for root path \"%s\".\n%s" - .formatted(rootDirRegex, e.getMessage())); + .formatted(rootDirPath, e.getMessage())); } }