Skip to content

Commit

Permalink
add each analysis name to a json file
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardomerlin committed Oct 25, 2024
1 parent 9f42ed1 commit 326da85
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions analyses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"analyses": []
}
29 changes: 24 additions & 5 deletions code-analysis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,33 @@ function complexityTrends {
}

function copyFiles {
log "Copying files..."
log "Copying files..."

cp /usr/src/code-analysys/complexity-file-trend.html "$COMPLEXITY_TRENDS_FOLDER"
cp /usr/src/code-analysys/hotspots.html "$ANALYSIS_FOLDER"
cp /usr/src/code-analysys/server.js "$HOTSPOTS_FOLDER"
cp /usr/src/code-analysys/complexity-file-trend.html "$COMPLEXITY_TRENDS_FOLDER"
cp /usr/src/code-analysys/hotspots.html "$ANALYSIS_FOLDER"
cp /usr/src/code-analysys/server.js "$HOTSPOTS_FOLDER"
if [ ! -f "$HOTSPOTS_FOLDER/analyses.json" ]; then
cp /usr/src/code-analysys/analyses.json "$HOTSPOTS_FOLDER"
fi

logDone
logDone
}

function addAnalysisToJson {
log "Updating analyses.json..."
local json_file="$HOTSPOTS_FOLDER/analyses.json"

# Read the JSON file
local json_content=$(cat "$json_file")

# Use jq to add the analysis folder name to the analyses array
local updated_json=$(echo "$json_content" | jq --arg folder "$ANALYSIS_FOLDER_NAME" '.analyses += [$folder]')

# Write the updated JSON back to the file
echo "$updated_json" > "$json_file"

logDone
}

startDate=$1
if [ -z "$startDate" ]
Expand All @@ -129,6 +147,7 @@ then
fi

copyFiles
addAnalysisToJson
retrieveGitLogs $startDate
countLinesOfCode
calculateChangeFrequencies
Expand Down
2 changes: 2 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apk add --no-cache python3
RUN apk add --no-cache curl
RUN apk add --no-cache bash
RUN apk add --no-cache openjdk11
RUN apk add --no-cache jq

# install clojure
RUN curl -O https://download.clojure.org/install/linux-install-1.10.3.822.sh
Expand Down Expand Up @@ -52,5 +53,6 @@ COPY hotspots.html .
COPY complexity-file-trend.html .
COPY code-analysis.sh .
COPY server.js .
COPY analyses.json .

ENTRYPOINT ["bash", "code-analysis.sh"]

0 comments on commit 326da85

Please sign in to comment.