Skip to content

Commit

Permalink
Merge pull request FeKozma#16 from FeKozma/minor-change
Browse files Browse the repository at this point in the history
Changed languageLevel in misc.xml and updated README.md.
  • Loading branch information
Livila authored Feb 20, 2024
2 parents c3cd346 + bc73152 commit a7c0eea
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Running Gradle jobs
on:
push:
branches: []
pull_request:
branches: []

jobs:
testing:
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 52 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
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. <!-- TODO: Add run option/script that works "on the go". -->

#### Results ####
The results will be shown in the `/results/` folder,
15 changes: 7 additions & 8 deletions src/main/java/CodeCheck/ConfigInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down

0 comments on commit a7c0eea

Please sign in to comment.