Skip to content

Professionalize repo: refactor, tests, CI, docs - #1

Merged
netqo merged 6 commits into
mainfrom
chore/repo-hygiene
May 21, 2026
Merged

netqo merged 6 commits into
mainfrom
chore/repo-hygiene

Conversation

@netqo

@netqo netqo commented May 21, 2026

Copy link
Copy Markdown
Owner

Summary

Five atomic commits that bring the repo up to the same quality bar applied recently to mullvad-socks5-probe: code refactor with clean-code/KISS/DRY/YAGNI passes, real unit tests, GitHub Actions CI, tooling configs, and a rewritten README with neutral framing.

  • refactor: collapse to standard Go layout and simplify abstractions
    Fixes the module path to github.com/<owner>/ProxyRiskScoreChecker, moves to cmd/proxyriskscore/ + internal/proxy + internal/ipqs, deletes the models and logging packages and the duplicated ProxyConverter interface, drops dead ValidateAndSaveProxies code, switches custom Logger to log/slog, replaces interactive stdin prompts with flag-based CLI (--input, --output, --strictness, --api-key, --timeout), uses fmt.Errorf("%w", ...) throughout for proper error wrapping. Drops the intermediate validproxys.txt output.
  • test: add unit tests for proxy parser and IPQS client
    Table-driven tests for every supported input format in proxy.Parse plus a matrix of invalid inputs. httptest-backed tests for the IPQS client covering happy path, upstream failure messages, non-200 HTTP, and malformed JSON.
  • chore: add editorconfig, golangci config and expand gitignore
  • ci: add GitHub Actions workflow for build, test, format and lint
    Two jobs: build-test (gofmt verify, vet, build, test -race) and lint (golangci-lint v1.62). Both pinned to Go 1.24 with build cache.
  • docs(readme): rewrite with neutral framing, badges and migration notes
    Replaces the prior "validate the reliability, anonymity and security of proxy servers... not blacklisted, associated with botnets, or otherwise flagged for malicious activity" framing with an honest description of what the tool does (batch IPQS reputation lookups), plus an explicit intended-use framing (operators monitoring their own proxy fleet), an enumeration of external services contacted, usage examples, and a migration section listing all breaking changes vs the prior interactive version.

Breaking changes (all surfaced in the README migration section)

  • Env var API_KEY -> IPQS_API_KEY.
  • Interactive prompts replaced by CLI flags.
  • Default output renamed proxies_risk_score_0.txt -> clean.txt.
  • Intermediate validproxys.txt file no longer written.

Test plan

  • go build ./... clean at every commit (bisect-safe).
  • go vet ./... clean.
  • go test -race -count=1 ./... passes (8 test cases across 2 packages).
  • gofmt -l . returns nothing.
  • Binary smoke-tested: --help exits 0, missing API key exits 2 with clear error, strictness validation rejects out-of-range values.
  • CI green on this PR (the workflow being added is what verifies it).

netqo added 6 commits May 21, 2026 20:10
Restructure the project around the standard cmd/ + internal/ layout and
strip the overengineering that accumulated in the original code.

Layout:
- Fix module path: ProxyRiskScoreChecker -> github.com/<owner>/ProxyRiskScoreChecker
- Move cmd/main/main.go -> cmd/proxyriskscore/main.go (binary name is the
  meaningful name, not "main")
- Collapse internal/proxyvalidate + internal/riskscore into internal/proxy
  and internal/ipqs respectively
- Delete internal/models (an interface defined where it's not consumed)
- Delete internal/logging (custom Logger / LogType / proxyLogger replaced
  by log/slog from the stdlib)
- Inline types.go files into their implementations (small packages,
  splitting types from impl was pure overhead)

Code quality:
- Drop the ProxyConverter interface (it was defined twice in two packages
  and only ever wrapped a single fmt.Sprintf call)
- Drop unused method proxyvalidate.ValidateAndSaveProxies (dead code)
- Drop the compile-time interface assertion that paired with the dropped
  models.ProxyValidator interface
- Inline the proxy URL building into Proxy.URL() method (single source of
  truth)
- Use fmt.Errorf with %w throughout for proper error wrapping
- Replace os.Getenv("API_KEY") with explicit env lookup against
  IPQS_API_KEY (descriptive name; breaking change is documented in the
  README migration section)

CLI:
- Replace interactive stdin prompts with flag-based CLI:
  --input, --output, --strictness, --api-key, --timeout, --help
- Handle flag.ErrHelp explicitly so --help exits 0 instead of 2
- Drop the intermediate validproxys.txt output file (it leaked an
  internal validation step as a side effect)

Logging:
- Replace custom Logger interface and proxyLogger struct with
  slog.New(slog.NewTextHandler(os.Stderr, nil)). The custom abstraction
  added 50 lines of plumbing for what slog provides as a one-liner.
- internal/proxy: table-driven tests covering each supported input format
  and a separate matrix of invalid inputs that must error
- internal/ipqs: httptest-backed tests for the happy path, upstream
  failure messages, non-200 HTTP responses, and malformed JSON

The proxy.Validator path is not covered yet: it requires a fixture
SOCKS5/HTTP proxy to test in isolation. Tracked in the README roadmap.
- .editorconfig: cross-editor whitespace and EOL rules, with Go set to
  tab indentation (matches gofmt) and YAML/JSON to 2-space
- .golangci.yml: enable errcheck, govet, ineffassign, staticcheck,
  unused, gofmt, goimports, misspell, unconvert, prealloc, revive.
  Tests exempted from errcheck for ergonomic test setup
- .gitignore: cover build/release/dist directories, tool output files,
  common editor noise, OS metadata, .env files
Two jobs on ubuntu-latest, both pinned to Go 1.24 with build cache:

- build-test: gofmt verification (fails on any output), go vet,
  go build ./..., go test -race -count=1 ./...
- lint: golangci-lint v1.62 via the official action

The lint job runs in parallel to keep total wall time low.
Replace the previous framing ("validate the reliability, anonymity and
security of proxy servers... ensuring your proxy endpoints are not
blacklisted, associated with botnets, or otherwise flagged for malicious
activity") with a description of what the tool actually does: query the
IPQS reputation API for a batch of proxies and report each one's
returned fraud_score.

Add an explicit "intended use" framing (operators monitoring their own
proxy fleet's IPQS reputation) and an enumeration of the external
services contacted.

Restructure the document into Overview, Build, Usage, Quality and
Conventions sections, plus a Roadmap and a Migration section listing
the breaking changes vs the previous interactive-CLI version
(IPQS_API_KEY env var, flag-based interface, renamed output file,
dropped intermediate file).

Add CI / Go / License badges.
The project uses log/slog (added in 1.21) and otherwise only stdlib
features available since Go 1.18, so 1.24 was an arbitrarily high
target that broke older golangci-lint binaries (the linter refuses to
analyze code targeting a Go version newer than itself).

CI still runs against Go 1.24; 1.21 here is only the minimum supported
version declared in go.mod.
@netqo
netqo merged commit 9d0adff into main May 21, 2026
2 checks passed
@netqo
netqo deleted the chore/repo-hygiene branch May 21, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant