Skip to content

Commit 9bae3df

Browse files
committed
Initial commit
0 parents  commit 9bae3df

215 files changed

Lines changed: 36177 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
IndentWidth: 4
5+
ColumnLimit: 100
6+
PointerAlignment: Left
7+
DerivePointerAlignment: false
8+
AlignConsecutiveAssignments: false
9+
AlignConsecutiveDeclarations: false
10+
AllowShortFunctionsOnASingleLine: Inline
11+
AllowShortIfStatementsOnASingleLine: Never
12+
AllowShortLoopsOnASingleLine: false
13+
BreakBeforeBraces: Attach
14+
NamespaceIndentation: None
15+
SortIncludes: true

.codacy/cli.sh

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env bash
2+
3+
4+
set -e +o pipefail
5+
6+
# Set up paths first
7+
bin_name="codacy-cli-v2"
8+
9+
# Determine OS-specific paths
10+
os_name=$(uname)
11+
arch=$(uname -m)
12+
13+
case "$arch" in
14+
"x86_64")
15+
arch="amd64"
16+
;;
17+
"x86")
18+
arch="386"
19+
;;
20+
"aarch64"|"arm64")
21+
arch="arm64"
22+
;;
23+
esac
24+
25+
if [ -z "$CODACY_CLI_V2_TMP_FOLDER" ]; then
26+
if [ "$(uname)" = "Linux" ]; then
27+
CODACY_CLI_V2_TMP_FOLDER="$HOME/.cache/codacy/codacy-cli-v2"
28+
elif [ "$(uname)" = "Darwin" ]; then
29+
CODACY_CLI_V2_TMP_FOLDER="$HOME/Library/Caches/Codacy/codacy-cli-v2"
30+
else
31+
CODACY_CLI_V2_TMP_FOLDER=".codacy-cli-v2"
32+
fi
33+
fi
34+
35+
version_file="$CODACY_CLI_V2_TMP_FOLDER/version.yaml"
36+
37+
38+
get_version_from_yaml() {
39+
if [ -f "$version_file" ]; then
40+
local version=$(grep -o 'version: *"[^"]*"' "$version_file" | cut -d'"' -f2)
41+
if [ -n "$version" ]; then
42+
echo "$version"
43+
return 0
44+
fi
45+
fi
46+
return 1
47+
}
48+
49+
get_latest_version() {
50+
local response
51+
if [ -n "$GH_TOKEN" ]; then
52+
response=$(curl -Lq --header "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/codacy/codacy-cli-v2/releases/latest" 2>/dev/null)
53+
else
54+
response=$(curl -Lq "https://api.github.com/repos/codacy/codacy-cli-v2/releases/latest" 2>/dev/null)
55+
fi
56+
57+
handle_rate_limit "$response"
58+
local version=$(echo "$response" | grep -m 1 tag_name | cut -d'"' -f4)
59+
echo "$version"
60+
}
61+
62+
handle_rate_limit() {
63+
local response="$1"
64+
if echo "$response" | grep -q "API rate limit exceeded"; then
65+
fatal "Error: GitHub API rate limit exceeded. Please try again later"
66+
fi
67+
}
68+
69+
download_file() {
70+
local url="$1"
71+
72+
echo "Downloading from URL: ${url}"
73+
if command -v curl > /dev/null 2>&1; then
74+
curl -# -LS "$url" -O
75+
elif command -v wget > /dev/null 2>&1; then
76+
wget "$url"
77+
else
78+
fatal "Error: Could not find curl or wget, please install one."
79+
fi
80+
}
81+
82+
download() {
83+
local url="$1"
84+
local output_folder="$2"
85+
86+
( cd "$output_folder" && download_file "$url" )
87+
}
88+
89+
download_cli() {
90+
# OS name lower case
91+
suffix=$(echo "$os_name" | tr '[:upper:]' '[:lower:]')
92+
93+
local bin_folder="$1"
94+
local bin_path="$2"
95+
local version="$3"
96+
97+
if [ ! -f "$bin_path" ]; then
98+
echo "📥 Downloading CLI version $version..."
99+
100+
remote_file="codacy-cli-v2_${version}_${suffix}_${arch}.tar.gz"
101+
url="https://github.com/codacy/codacy-cli-v2/releases/download/${version}/${remote_file}"
102+
103+
download "$url" "$bin_folder"
104+
tar xzfv "${bin_folder}/${remote_file}" -C "${bin_folder}"
105+
fi
106+
}
107+
108+
# Warn if CODACY_CLI_V2_VERSION is set and update is requested
109+
if [ -n "$CODACY_CLI_V2_VERSION" ] && [ "$1" = "update" ]; then
110+
echo "⚠️ Warning: Performing update with forced version $CODACY_CLI_V2_VERSION"
111+
echo " Unset CODACY_CLI_V2_VERSION to use the latest version"
112+
fi
113+
114+
# Ensure version.yaml exists and is up to date
115+
if [ ! -f "$version_file" ] || [ "$1" = "update" ]; then
116+
echo "ℹ️ Fetching latest version..."
117+
version=$(get_latest_version)
118+
mkdir -p "$CODACY_CLI_V2_TMP_FOLDER"
119+
echo "version: \"$version\"" > "$version_file"
120+
fi
121+
122+
# Set the version to use
123+
if [ -n "$CODACY_CLI_V2_VERSION" ]; then
124+
version="$CODACY_CLI_V2_VERSION"
125+
else
126+
version=$(get_version_from_yaml)
127+
fi
128+
129+
130+
# Set up version-specific paths
131+
bin_folder="${CODACY_CLI_V2_TMP_FOLDER}/${version}"
132+
133+
mkdir -p "$bin_folder"
134+
bin_path="$bin_folder"/"$bin_name"
135+
136+
# Download the tool if not already installed
137+
download_cli "$bin_folder" "$bin_path" "$version"
138+
chmod +x "$bin_path"
139+
140+
run_command="$bin_path"
141+
if [ -z "$run_command" ]; then
142+
fatal "Codacy cli v2 binary could not be found."
143+
fi
144+
145+
if [ "$#" -eq 1 ] && [ "$1" = "download" ]; then
146+
echo "Codacy cli v2 download succeeded"
147+
else
148+
eval "$run_command $*"
149+
fi

.codacy/codacy.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
runtimes:
2+
- java@17.0.10
3+
- node@22.2.0
4+
- python@3.11.11
5+
tools:
6+
- eslint@8.57.0
7+
- lizard@1.17.31
8+
- pmd@6.55.0
9+
- semgrep@1.78.0
10+
- trivy@0.66.0
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
description: Configuration for AI behavior when interacting with Codacy's MCP Server
3+
applyTo: '**'
4+
---
5+
---
6+
# Codacy Rules
7+
Configuration for AI behavior when interacting with Codacy's MCP Server
8+
9+
## using any tool that accepts the arguments: `provider`, `organization`, or `repository`
10+
- ALWAYS use:
11+
- provider: gh
12+
- organization: bitcoin-core
13+
- repository: secp256k1
14+
- Avoid calling `git remote -v` unless really necessary
15+
16+
## CRITICAL: After ANY successful `edit_file` or `reapply` operation
17+
- YOU MUST IMMEDIATELY run the `codacy_cli_analyze` tool from Codacy's MCP Server for each file that was edited, with:
18+
- `rootPath`: set to the workspace path
19+
- `file`: set to the path of the edited file
20+
- `tool`: leave empty or unset
21+
- If any issues are found in the new edits, propose and apply fixes for them.
22+
- > NOTE: Failure to follow this rule is considered a critical error.
23+
24+
## When you tried to run the `codacy_cli_analyze` tool and the Codacy CLI is not installed
25+
- Ask the user 'Codacy CLI is not installed. Would you like me to install it now?'
26+
- If the user responds with "yes", run the `codacy_cli_install` tool and then continue with the original task
27+
- If the user responds with "no", instruct the user that they can disable automatic analysis in the extension settings
28+
- Wait for the user to respond before proceeding with any other actions
29+
30+
## After every response
31+
- If you made any file edits in this conversation, verify you ran `codacy_cli_analyze` tool from Codacy's MCP Server
32+
33+
## When there are no Codacy MCP Server tools available, or the MCP Server is not reachable
34+
- Suggest the user the following troubleshooting steps:
35+
- Try to reset the MCP on the extension
36+
- If the user is using VSCode, suggest them to review their Copilot > MCP settings in Github, under their organization or personal account. Refer them to Settings > Copilot > Enable MCP servers in Copilot. Suggested URL (https://github.com/settings/copilot/features) or https://github.com/organizations/{organization-name}/settings/copilot/features (This can only be done by their organization admins / owners)
37+
- If none of the above steps work, suggest the user to contact Codacy support
38+
39+
## Trying to call a tool that needs a rootPath as a parameter
40+
- Always use the standard, non-URL-encoded file system path
41+
42+
## CRITICAL: Dependencies and Security Checks
43+
- IMMEDIATELY after ANY of these actions:
44+
- Running npm/yarn/pnpm install
45+
- Adding dependencies to package.json
46+
- Adding requirements to requirements.txt
47+
- Adding dependencies to pom.xml
48+
- Adding dependencies to build.gradle
49+
- Any other package manager operations
50+
- You MUST run the `codacy_cli_analyze` tool with:
51+
- `rootPath`: set to the workspace path
52+
- `tool`: set to "trivy"
53+
- `file`: leave empty or unset
54+
- If any vulnerabilities are found because of the newly added packages:
55+
- Stop all other operations
56+
- Propose and apply fixes for the security issues
57+
- Only continue with the original task after security issues are resolved
58+
- EXAMPLE:
59+
- After: npm install react-markdown
60+
- Do: Run codacy_cli_analyze with trivy
61+
- Before: Continuing with any other tasks
62+
63+
## General
64+
- Repeat the relevant steps for each modified file.
65+
- "Propose fixes" means to both suggest and, if possible, automatically apply the fixes.
66+
- You MUST NOT wait for the user to ask for analysis or remind you to run the tool.
67+
- Do not run `codacy_cli_analyze` looking for changes in duplicated code or code complexity metrics.
68+
- Complexity metrics are different from complexity issues. When trying to fix complexity in a repository or file, focus on solving the complexity issues and ignore the complexity metric.
69+
- Do not run `codacy_cli_analyze` looking for changes in code coverage.
70+
- Do not try to manually install Codacy CLI using either brew, npm, npx, or any other package manager.
71+
- If the Codacy CLI is not installed, just run the `codacy_cli_analyze` tool from Codacy's MCP Server.
72+
- When calling `codacy_cli_analyze`, only send provider, organization and repository if the project is a git repository.
73+
74+
## Whenever a call to a Codacy tool that uses `repository` or `organization` as a parameter returns a 404 error
75+
- Offer to run the `codacy_setup_repository` tool to add the repository to Codacy
76+
- If the user accepts, run the `codacy_setup_repository` tool
77+
- Do not ever try to run the `codacy_setup_repository` tool on your own
78+
- After setup, immediately retry the action that failed (only retry once)
79+
---

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
build:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest]
15+
build_type: [Debug, Release]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
22+
- name: Install dependencies (Ubuntu)
23+
if: runner.os == 'Linux'
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y cmake ninja-build libssl-dev
27+
28+
- name: Install dependencies (macOS)
29+
if: runner.os == 'macOS'
30+
run: |
31+
brew install cmake ninja openssl
32+
33+
- name: Setup vcpkg
34+
uses: lukka/run-vcpkg@v11
35+
with:
36+
vcpkgGitCommitId: 'master'
37+
38+
- name: Configure CMake
39+
run: |
40+
cmake -B build -S . \
41+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
42+
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
43+
-G Ninja
44+
45+
- name: Build
46+
run: cmake --build build --config ${{ matrix.build_type }}
47+
48+
- name: Test
49+
run: ctest --test-dir build --config ${{ matrix.build_type }} --output-on-failure

.gitignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
ecies-lib/
2+
3+
# Build directories
4+
build/
5+
cmake-build-*/
6+
out/
7+
8+
# TypeScript / Node.js
9+
node_modules/
10+
dist/
11+
*.tsbuildinfo
12+
.turbo/
13+
.eslintcache
14+
15+
*~
16+
17+
# Compiled files
18+
*.o
19+
*.a
20+
*.so
21+
*.dylib
22+
*.dll
23+
*.exe
24+
25+
# Test data
26+
brightchain_data/
27+
test_data/
28+
29+
# vcpkg
30+
vcpkg_installed/
31+
32+
# macOS
33+
.DS_Store
34+
*.xcuserstate
35+
36+
# Coverage
37+
*.gcov
38+
*.gcda
39+
*.gcno
40+
coverage/
41+
42+
# Xcode / Swift
43+
## User settings
44+
xcuserdata/
45+
*.xcscmblueprint
46+
*.xccheckout
47+
48+
## Build generated
49+
DerivedData/
50+
*.build/
51+
*.hmap
52+
*.ipa
53+
*.dSYM.zip
54+
*.dSYM
55+
56+
## Playgrounds
57+
timeline.xctimeline
58+
playground.xcworkspace
59+
60+
## Swift Package Manager
61+
.swiftpm/
62+
.build/
63+
Packages/
64+
Package.resolved
65+
66+
## CocoaPods (if used)
67+
Pods/
68+
Podfile.lock
69+
70+
## Carthage (if used)
71+
Carthage/Build/
72+
Carthage/Checkouts/
73+
74+
## fastlane
75+
fastlane/report.xml
76+
fastlane/Preview.html
77+
fastlane/screenshots/**/*.png
78+
fastlane/test_output
79+
80+
## Code Injection
81+
iOSInjectionProject/
82+
83+
## Provisioning profiles (keep these private)
84+
*.mobileprovision
85+
*.provisionprofile
86+
87+
## Archives
88+
*.xcarchive

0 commit comments

Comments
 (0)