Skip to content

Commit 0669ff7

Browse files
authored
Merge pull request #195 from JohT/feature/use-kontext-e-jqassistant-git-plugin
Support scanning files outside "artifacts" and switch to plugin for git data
2 parents 6ff19ac + 5263a55 commit 0669ff7

23 files changed

+241
-97
lines changed

.github/workflows/java-code-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
env:
132132
NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
133133
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true"
134-
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "full" # Options: "none", "aggregated", "full"
134+
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "" # Options: "none", "aggregated", "full". default = "plugin" or ""
135135
run: |
136136
./../../scripts/analysis/analyze.sh
137137

.github/workflows/typescript-code-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs:
140140
env:
141141
NEO4J_INITIAL_PASSWORD: ${{ secrets.NEO4J_INITIAL_PASSWORD }}
142142
ENABLE_JUPYTER_NOTEBOOK_PDF_GENERATION: "true"
143-
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "full" # Options: "none", "aggregated", "full"
143+
IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT: "" # Options: "none", "aggregated", "full". default = "plugin" or ""
144144
run: |
145145
./../../scripts/analysis/analyze.sh
146146

COMMANDS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ The optional parameter `--source directory-path-to-the-source-folder-containing-
300300

301301
#### Environment Variable
302302

303-
- `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT` supports the values `none`, `aggregated` and `full` (default). With it, you can switch off git import (`none`), import aggregated data for a smaller memory footprint (`aggregated`) or import all git commits and the files that where changed with them (`full`=default) .
303+
- `IMPORT_GIT_LOG_DATA_IF_SOURCE_IS_PRESENT` supports the values `none`, `aggregated`, `full` and `plugin` (default). With it, you can switch off git import (`none`), import aggregated data for a smaller memory footprint (`aggregated`), import all commits with git log in a simple way (`full`) or let a plugin take care of git data (`plugin`= `""`=default) .
304304

305305
#### Resolving git files to code files
306306

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ This could be as simple as running the following command in your Typescript proj
9191
npx --yes @jqassistant/ts-lce
9292
```
9393

94-
- It is recommended to put the cloned source code repository into a directory called `source` within the analysis workspace so that it will also be picked up to import git log data.
95-
96-
- Copy the resulting json file (e.g. `.reports/jqa/ts-output.json`) into the `artifacts/typescript` directory for your analysis work directory. Create the directory, if it doesn't exists. Custom subdirectories within `artifacts/typescript` are also supported.
94+
- The cloned repository or source project needs to be copied into the directory called `source` within the analysis workspace, so that it will also be picked up during scan by [resetAndScan.sh](./scripts/resetAndScan.sh) and optional [importGit.sh](./scripts/importGit.sh).
9795

9896
## :rocket: Getting Started
9997

cypher/GitLog/Add_RESOLVES_TO_relationships_to_git_files_for_Java.cypher

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ MATCH (code_file:File&!Git)
77
WHERE NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) } // only original nodes, no duplicates
88
WITH code_file, replace(code_file.fileName, '.class', '.java') AS codeFileName
99
MATCH (git_file:File&Git)
10-
WHERE git_file.fileName ENDS WITH codeFileName
10+
WITH *
11+
,git_file
12+
,coalesce(git_file.fileName, git_file.relativePath) AS gitFileName
13+
WHERE gitFileName ENDS WITH codeFileName
1114
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
1215
SET git_file.resolved = true
1316
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
14-
,collect(DISTINCT codeFileName + ' <-> ' + git_file.fileName + '\n')[0..4] AS examples
17+
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples

cypher/GitLog/Add_RESOLVES_TO_relationships_to_git_files_for_Typescript.cypher

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ MATCH (code_file:File&!Git)
77
WHERE NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) } // only original nodes, no duplicates
88
WITH code_file, code_file.absoluteFileName AS codeFileName
99
MATCH (git_file:File&Git)
10-
WHERE codeFileName ENDS WITH git_file.fileName
10+
WITH *
11+
,git_file
12+
,coalesce(git_file.fileName, git_file.relativePath) AS gitFileName
13+
WHERE codeFileName ENDS WITH gitFileName
1114
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
1215
SET git_file.resolved = true
1316
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
14-
,collect(DISTINCT codeFileName + ' <-> ' + git_file.fileName + '\n')[0..4] AS examples
17+
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples

cypher/GitLog/Import_git_log_csv_data.cypher

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CALL { WITH row
55
MATCH (git_repository:Git:Repository{absoluteFileName: $git_repository_absolute_directory_name})
66
MERGE (git_author:Git:Log:Author {name: row.author, email: row.email})
77
MERGE (git_commit:Git:Log:Commit {
8+
sha: row.hash,
89
hash: row.hash,
910
parent: coalesce(row.parent, ''),
1011
message: row.message,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Create index for git commit sha
2+
3+
CREATE INDEX INDEX_COMMIT_HASH IF NOT EXISTS FOR (commit:Commit) ON (commit.sha)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Create index for the relative file path
2+
3+
CREATE INDEX INDEX_FILE_NAME IF NOT EXISTS FOR (file:File) ON (file.relativePath)

cypher/GitLog/Set_number_of_git_commits.cypher renamed to cypher/GitLog/Set_number_of_git_log_commits.cypher

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ MATCH (code_file:File&!Git)<-[:RESOLVES_TO]-(git_file:File&Git)
44
MATCH (git_file)<-[:CONTAINS_CHANGED]-(git_commit:Git:Commit)
55
WITH code_file, count(DISTINCT git_commit.hash) AS numberOfGitCommits
66
SET code_file.numberOfGitCommits = numberOfGitCommits
7-
RETURN count(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName)) AS changedCodeFiles
7+
RETURN count(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName)) AS changedCodeFiles
8+
//,collect(DISTINCT coalesce(code_file.absoluteFileName, code_file.fileName))[0..4] AS examples

0 commit comments

Comments
 (0)