Skip to content

Commit fdcc43f

Browse files
committed
Simpler refactoring than before due to bugs
1 parent 4a12c85 commit fdcc43f

File tree

7 files changed

+606
-1028
lines changed

7 files changed

+606
-1028
lines changed

.golangci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,24 @@ linters:
2828

2929
# Architecture and interface linters (key for your request)
3030
- interfacebloat # Detect interfaces with too many methods
31-
- ireturn # Accept interfaces, return concrete types
3231
- unparam # Report unused function parameters
3332

3433
# Code quality linters
3534
- asciicheck # Check for non-ASCII identifiers
3635
- bidichk # Check for dangerous unicode sequences
3736
- bodyclose # Check HTTP response body is closed
3837
- contextcheck # Check context usage
39-
- cyclop # Check cyclomatic complexity
4038
- dupl # Check for code duplication
4139
- durationcheck # Check duration multiplication
4240
- errname # Check error naming conventions
4341
- errorlint # Check error wrapping
4442
- exhaustive # Check enum switch exhaustiveness
45-
- funlen # Check function length
46-
- gocognit # Check cognitive complexity
4743
- goconst # Find repeated strings that could be constants
48-
- gocritic # Comprehensive Go source code linter
49-
- gocyclo # Check cyclomatic complexity
5044
- godox # Find TODO, FIXME, etc. comments
5145
- goprintffuncname # Check printf-style function names
5246
- gosec # Security-focused linter
5347
- misspell # Check for misspellings
5448
- nakedret # Check naked returns
55-
- nestif # Check deeply nested if statements
5649
- nilerr # Check nil error returns
5750
- nolintlint # Check nolint directives
5851
- predeclared # Check for shadowed predeclared identifiers
@@ -81,3 +74,11 @@ linters:
8174
- maintidx # Maintainability index can be subjective
8275
- godot # Check comments end with period
8376
- lll # Check line length
77+
- ireturn # Interface return types are sometimes necessary
78+
# ignore for now
79+
- nestif
80+
- gocognit
81+
- gocyclo # Check cyclomatic complexity
82+
- cyclop # Check cyclomatic complexity
83+
- funlen # Check function length
84+
- gocritic

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ USAGE:
214214
jcmd (supports --args)
215215
Run a JCMD command on a running Java application via --args, downloads
216216
and deletes all files that are created in the current folder, use
217-
'--no-download' to prevent this
217+
'--no-download' to prevent this. Environment variables available:
218+
@FSPATH (writable directory path, always set), @ARGS (command
219+
arguments), @APP_NAME (application name), @FILE_NAME (generated filename
220+
for file operations without UUID), and @STATIC_FILE_NAME (without UUID).
221+
Use single quotes around --args to prevent shell expansion.
218222

219223
jfr-start
220224
Start a Java Flight Recorder default recording on a running Java
@@ -255,7 +259,11 @@ USAGE:
255259
the current folder. Don't use in combination with asprof-* commands.
256260
Downloads and deletes all files that are created in the current folder,
257261
if not using 'start' asprof command, use '--no-download' to prevent
258-
this.
262+
this. Environment variables available: @FSPATH (writable directory path,
263+
always set), @ARGS (command arguments), @APP_NAME (application name),
264+
@FILE_NAME (generated filename for file operations), and
265+
@STATIC_FILE_NAME (without UUID). Use single quotes around --args to
266+
prevent shell expansion.
259267

260268
asprof-start-cpu (recent SapMachine only)
261269
Start an async-profiler CPU-time profile recording on a running Java
@@ -280,9 +288,12 @@ USAGE:
280288
Get the status of async-profiler on a running Java application
281289

282290
OPTIONS:
283-
-app-instance-index -i, [index], select to which instance of the app to connect
284291
-args -a, Miscellaneous arguments to pass to the command (if supported) in the
285-
container, be aware to end it with a space if it is a simple option
292+
container, be aware to end it with a space if it is a simple option. For
293+
commands that create arbitrary files (jcmd, asprof), the environment
294+
variables @FSPATH, @ARGS, @APP_NAME, @FILE_NAME, and @STATIC_FILE_NAME are
295+
available in --args to reference the working directory path, arguments,
296+
application name, and generated file name respectively.
286297
-container-dir -cd, the directory path in the container that the heap dump/JFR/... file will be
287298
saved to
288299
-dry-run -n, just output to command line what would be executed
@@ -293,6 +304,7 @@ OPTIONS:
293304
-no-download -nd, don't download the heap dump/JFR/... file to local, only keep it in the
294305
container, implies '--keep'
295306
-verbose -v, enable verbose output for the plugin
307+
-app-instance-index -i [index], select to which instance of the app to connect
296308

297309
</pre>
298310

TESTING.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## 🎯 Overview
44

5-
The CF Java Plugin now includes comprehensive CI/CD integration with automated testing, linting, and quality assurance for both Go and Python codebases.
5+
The CF Java Plugin now includes comprehensive CI/CD integration with automated testing, linting,
6+
and quality assurance for both Go and Python codebases.
67

78
## 🏗️ CI/CD Pipeline
89

@@ -27,6 +28,7 @@ The CF Java Plugin now includes comprehensive CI/CD integration with automated t
2728
### Smart Python Detection
2829

2930
The CI automatically detects if the Python test suite exists by checking for:
31+
3032
- `test/requirements.txt`
3133
- `test/setup.sh`
3234

@@ -35,11 +37,13 @@ If found, runs Python linting validation. **Note: Python test execution is tempo
3537
## 🔒 Pre-commit Hooks
3638

3739
### Installation
40+
3841
```bash
3942
./setup-dev-env.sh # One-time setup
4043
```
4144

4245
### What It Checks
46+
4347
- ✅ Go code formatting (`go fmt`)
4448
- ✅ Go static analysis (`go vet`)
4549
- ✅ Python linting (flake8) - if test suite exists
@@ -49,19 +53,23 @@ If found, runs Python linting validation. **Note: Python test execution is tempo
4953
- ✅ Markdown linting (markdownlint) - checks git-tracked files
5054

5155
### Hook Behavior
56+
5257
- **Auto-fixes**: Python formatting and import sorting
5358
- **Blocks commits**: On critical linting issues
5459
- **Warnings**: For non-critical issues or missing Python suite
5560

5661
## 🧪 Python Test Suite Integration
5762

5863
### Linting Standards
64+
5965
- **[flake8](https://flake8.pycqa.org/)**: Line length 120, ignores E203,W503
6066
- **[black](https://black.readthedocs.io/)**: Line length 120, compatible with flake8
6167
- **[isort](https://pycqa.github.io/isort/)**: Black-compatible profile for import sorting
62-
- **[markdownlint](https://github.com/DavidAnson/markdownlint)**: Automated markdown formatting (120 char limit, git-tracked files only)
68+
- **[markdownlint](https://github.com/DavidAnson/markdownlint)**: Automated markdown formatting
69+
(120 char limit, git-tracked files only)
6370

6471
### Manual Usage
72+
6573
```bash
6674
./scripts/lint-go.sh check # Check Go code formatting and static analysis
6775
./scripts/lint-go.sh fix # Auto-fix Go code issues
@@ -73,6 +81,7 @@ If found, runs Python linting validation. **Note: Python test execution is tempo
7381
```
7482

7583
### Test Execution
84+
7685
```bash
7786
cd test
7887
./setup.sh # Setup environment
@@ -82,20 +91,23 @@ cd test
8291
**CI Status**: Python tests are currently disabled in CI workflows but can be run locally.
8392

8493
### Coverage Reporting
94+
8595
- Generated in XML format for Codecov integration
8696
- Covers the `framework` module
8797
- Includes terminal output for local development
8898

8999
## 🛠️ Development Workflow
90100

91101
### First-time Setup
102+
92103
```bash
93104
git clone <repository>
94105
cd cf-cli-java-plugin
95106
./setup-dev-env.sh
96107
```
97108

98109
### Daily Development
110+
99111
```bash
100112
# Make changes
101113
code cf-java-plugin.code-workspace
@@ -111,6 +123,7 @@ git push origin feature-branch
111123
```
112124

113125
### Manual Testing
126+
114127
```bash
115128
# Test pre-commit hooks
116129
.git/hooks/pre-commit
@@ -125,15 +138,18 @@ cd test && pytest test_jfr.py -v
125138
## 📊 Quality Metrics
126139

127140
### Go Code Quality
141+
128142
- Formatting enforcement via `go fmt`
129143
- Static analysis via `go vet`
130144

131145
### Python Code Quality
146+
132147
- Style compliance: flake8 (PEP 8 + custom rules)
133148
- Formatting: black (consistent style)
134149
- Import organization: isort (proper import ordering)
135150

136151
### Markdown Code Quality
152+
137153
- Style compliance: markdownlint (120 char limit, git-tracked files only)
138154
- Automated formatting with relaxed rules for compatibility
139155

@@ -168,6 +184,7 @@ For running Python tests in CI that require Cloud Foundry credentials, configure
168184
### Environment Variable Usage
169185

170186
The Python test framework automatically uses these environment variables:
187+
171188
- Falls back to `test_config.yml` if environment variables are not set
172189
- Supports both file-based and environment-based configuration
173190
- CI workflows pass secrets as environment variables to test processes

0 commit comments

Comments
 (0)