Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Use these optional command line options as needed:
./init.sh MyAnalysisProjectName
```

- Change into the analysis directory.

```shell
cd ./temp/MyAnalysisProjectName
```

### 2. Prepare the code to be analyzed

- Move the artifacts (e.g. Java jars json files) you want to analyze into the `artifacts` directory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// The differences are subtle but need to be thought through and tested carefully.
// Having separate files makes it obvious that there needs to be one for every new source code language.

MATCH (code_file:!Git&File)
MATCH (code_file:!Git&File&!Directory)
WHERE code_file.fileName IS NOT NULL
// Use only original code files, no resolved duplicates
AND NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) }
Expand All @@ -17,8 +17,10 @@ MATCH (git_file:Git&File)
,git_file
,coalesce(git_file.fileName, git_file.relativePath) AS gitFileName
WHERE gitFileName ENDS WITH codeFileName
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
SET git_file.resolved = true
CALL { WITH git_file, code_file
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
ON CREATE SET git_file.resolved = true
} IN TRANSACTIONS
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples
// RETURN codeFileName, gitFileName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// The differences are subtle but need to be thought through and tested carefully.
// Having separate files makes it obvious that there needs to be one for every new source code language.

MATCH (code_file:!Git&File)
MATCH (code_file:!Git&File&!Directory&!Scan)
WHERE (code_file.absoluteFileName IS NOT NULL OR code_file.fileName IS NOT NULL)
// Use only original code files, no resolved duplicates
AND NOT EXISTS { (code_file)-[:RESOLVES_TO]->(other_file:File&!Git) }
WITH code_file
,coalesce(code_file.absoluteFileName, code_file.fileName) AS codeFileName
MATCH (git_file:Git&File)
WHERE codeFileName ENDS WITH git_file.fileName
OR codeFileName ENDS WITH git_file.relativePath
// Use repository if available to overcome ambiguity in multi source analysis
OPTIONAL MATCH (git_repository:Git&Repository)-[:HAS_FILE]->(git_file)
WITH *
Expand All @@ -19,8 +19,10 @@ OPTIONAL MATCH (git_repository:Git&Repository)-[:HAS_FILE]->(git_file)
,coalesce(git_repository.name + '/', '') + git_file.relativePath
) AS gitFileName
WHERE codeFileName ENDS WITH gitFileName
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
SET git_file.resolved = true
CALL { WITH git_file, code_file
MERGE (git_file)-[:RESOLVES_TO]->(code_file)
ON CREATE SET git_file.resolved = true
} IN TRANSACTIONS
RETURN count(DISTINCT codeFileName) AS numberOfCodeFiles
,collect(DISTINCT codeFileName + ' <-> ' + gitFileName + '\n')[0..4] AS examples
// RETURN codeFileName, gitFileName
Expand Down
18 changes: 14 additions & 4 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ if [ -z "${NEO4J_INITIAL_PASSWORD}" ]; then
exit 1
fi

createForwardingScript() {
local originalScript="${1}"
local scriptName;scriptName=$(basename "$originalScript")

cp -n "${originalScript}" .
echo "#!/usr/bin/env bash" > "./${scriptName}"
# shellcheck disable=SC2016
echo "${originalScript} \"\${@}\"" >> "./${scriptName}"
}

# Create the temporary directory for all analysis projects if it hadn't been created yet.
mkdir -p ./temp
cd ./temp
Expand All @@ -45,9 +55,9 @@ mkdir -p "./${ARTIFACTS_DIRECTORY}"
# Create the source directory inside the analysis directory for source code projects/repositories if it hadn't been created yet.
mkdir -p "./${SOURCE_DIRECTORY}"

# Create symbolic links to the most common scripts for code analysis.
ln -s "./../../scripts/analysis/analyze.sh" .
ln -s "./../../scripts/startNeo4j.sh" .
ln -s "./../../scripts/stopNeo4j.sh" .
# Create forwarding scripts for the most important commands
createForwardingScript "./../../scripts/analysis/analyze.sh"
createForwardingScript "./../../scripts/startNeo4j.sh"
createForwardingScript "./../../scripts/stopNeo4j.sh"

echo "init: Successfully initialized analysis project ${analysisName}" >&2
2 changes: 2 additions & 0 deletions scripts/detectChangedFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# A second call without this option will be needed for the change detection to work.
# This is helpful to decide if an operation should be done based on changes while waiting for its success to finally save the change state.
# --paths Comma-separated list of file- and directory-names that are used for calculating the hash based on their name and size.
# --hashfile Path to the file that contains the hash for change detection. Default in environment variable CHANGE_DETECTION_HASH_FILE_PATH

# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
set -o errexit -o pipefail
Expand Down Expand Up @@ -88,6 +89,7 @@ file_names_and_sizes() {
-type d -name "node_modules" -prune -o \
-type d -name "target" -prune -o \
-type d -name "temp" -prune -o \
-type d -name ".reports" -prune -o \
-not -path "${hashFilePath}" \
-type f \
-exec stat -f "%N %z" {} + \
Expand Down
Loading