Skip to content

stats#260

Merged
hugoh merged 14 commits into
mainfrom
stats
Jun 8, 2026
Merged

stats#260
hugoh merged 14 commits into
mainfrom
stats

Conversation

@hugoh

@hugoh hugoh commented Jun 8, 2026

Copy link
Copy Markdown
Owner
  • feat(stats): loop/downaction state
  • refactor(log): removed trace level
  • refactor(status): remove ErrInvalidRange from CalculateUptime
  • refactor: rename Checker → LoopChecker, inline types.Duration
  • test(status): add unit tests for Status setters
  • refactor: split internal into config + cli packages
  • test: add end-to-end integration test
  • refactor: int64 -> uint64
  • refactor(logger): component logging
  • refactor: cleanup
  • refactor: modernize
  • refactor(test): extracted helpers
  • refactor: modernize

hugoh added 13 commits June 8, 2026 18:30
Error return was dead weight — the only caller (GenReports) silently
discards it. CalculateUptime now returns (float64, time.Duration)
directly. Over-range periods return (-1, 0), producing "Not computed"
in JSON as before.

Removes ErrInvalidRange sentinel error and associated tests.
Checker → LoopChecker:
- LoopChecker replaces Checker struct (collision with check.Checker)
- Updated tests (loop_test.go)

Inline types.Duration into internal:
- Moved from internal/types/ into internal/duration.go
- Deleted internal/types/ directory
- Updated conf.go, conf_validate.go, conf_test.go to use Duration directly
Covers all four setters (SetDownActionStatus, SetLoopStatus,
SetLastSuccessAt, SetNextCheckAt) including zero/omit, overdue
clamping, and concurrent access scenarios.
Extracts configuration loading, validation, and the Duration type into
a new internal/config/ package (package config), leaving CLI/lifecycle
in internal/ (package internal).

- internal/config/config.go — Configuration struct, ReadConf, factory
  methods (GetChecks, GetDelays, GetDownAction, GetStatServerConfig)
  env-var expansion, probe creation
- internal/config/config_validate.go — field-level validation
- internal/config/duration.go — Duration type (moved from internal/)
- internal/config/config_test.go, config_validate_test.go,
  duration_test.go — corresponding tests
- internal/cmd.go — imports config package, SetupLoop uses
  config.ReadConf and config.Configuration
- internal/cmd_test.go — defines testConfigDir locally
- Deleted internal/conf.go, conf_validate.go, duration.go and their
  test files (now in internal/config/)
Two build-and-run integration tests tagged with //go:build integration:

- TestEndToEnd verifies the binary starts with a minimal config
- TestEndToEnd_StatsServer tests the full lifecycle: build, start with
  stats server on a known port, query /stats.json for valid JSON with
  expected fields, then clean shutdown via SIGINT.

Pattern follows existing version_integration_test.go convention.
@deepsource-io

deepsource-io Bot commented Jun 8, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 56ed78a...687f625 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Jun 8, 2026 11:48p.m. Review ↗
Secrets Jun 8, 2026 11:48p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread internal/status/stat-server_test.go Outdated
"github.com/stretchr/testify/require"
)

func startStatServer(t *testing.T, config *StatServerConfig) *StatServer {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method 'startStatServer' differs only by capitalization to function 'StartStatServer' in /home/runner/go/src/pkg.deepsource.io/sample/internal/status/stat-server.go


Methods or fields of struct that have names different only by capitalization
could be confusing.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.58065% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.84%. Comparing base (56ed78a) to head (687f625).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
internal/logger/logger.go 41.66% 7 Missing ⚠️
internal/config/config.go 62.50% 5 Missing and 1 partial ⚠️
internal/logic/downaction.go 82.60% 4 Missing ⚠️
internal/logic/loop.go 89.47% 4 Missing ⚠️
internal/status/stat-server.go 72.72% 3 Missing ⚠️
internal/status/status.go 94.28% 1 Missing and 1 partial ⚠️
internal/cmd.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
+ Coverage   83.91%   86.84%   +2.93%     
==========================================
  Files          18       18              
  Lines         920      859      -61     
==========================================
- Hits          772      746      -26     
+ Misses        116       82      -34     
+ Partials       32       31       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@hugoh hugoh merged commit 8b72cba into main Jun 8, 2026
7 checks passed
@hugoh hugoh deleted the stats branch June 8, 2026 23:49
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