Skip to content

Remove keychain storage, store tokens in config file#269

Merged
jai-deepsource merged 6 commits intomasterfrom
v2-improvements
Mar 1, 2026
Merged

Remove keychain storage, store tokens in config file#269
jai-deepsource merged 6 commits intomasterfrom
v2-improvements

Conversation

@jai-deepsource
Copy link
Contributor

  • Drop internal/secrets/ package and keychain integration
  • Simplify config manager to use TOML-only token storage
  • Default host when config is empty, backfill user from server
  • Fix subcommand help delegation

@deepsource-io
Copy link

deepsource-io bot commented Mar 1, 2026

DeepSource Code Review

We reviewed changes in e34608a...074fd63 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 ↗

Important

Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Mar 1, 2026 8:12p.m. Review ↗
Secrets Mar 1, 2026 8:12p.m. Review ↗
Test coverage Mar 1, 2026 8:12p.m. Review ↗

Code Coverage Summary

Language Line Coverage (New Code) Line Coverage (Overall)
Aggregate
18.8%
19.4%
Go
18.8%
[⤫ below threshold]
19.4%
[✓ above threshold]

➟ Additional coverage metrics may have been reported. See full coverage report ↗

- Drop internal/secrets/ package and keychain integration
- Simplify config manager to use TOML-only token storage
- Default host when config is empty, backfill user from server
- Fix subcommand help delegation

Signed-off-by: Jai Pradeesh <jai@deepsource.io>
- Remove redundant godoc and inline comments across codebase
- Extract auth status into smaller helper methods
- Add BackfillUser and default host logic to config manager
- Add tests for login edge cases, auth status, and config manager
)

// gitGetHead accepts a git directory and returns head commit OID / error
func gitGetHead(workspaceDir string) (headOID string, warning string, err error) {
Copy link

Choose a reason for hiding this comment

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

func gitGetHead is unused


It is recommended to keep the codebase clean by removing unused code.


// Fetches the latest commit hash using the command `git rev-parse HEAD`
// through git
func fetchHeadManually(directoryPath string) (string, error) {
Copy link

Choose a reason for hiding this comment

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

func fetchHeadManually is unused


It is recommended to keep the codebase clean by removing unused code.

}

// Handle special cases for GitHub Actions.
func getGitHubActionsCommit(topCommit string) (headOID string, warning string, err error) {
Copy link

Choose a reason for hiding this comment

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

func getGitHubActionsCommit is unused


It is recommended to keep the codebase clean by removing unused code.

}

// Return PR's HEAD ref set as env variable manually by DeepSource's Test coverage action.
func getTestCoverageActionCommit() (headOID string, err error) {
Copy link

Choose a reason for hiding this comment

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

func getTestCoverageActionCommit is unused


It is recommended to keep the codebase clean by removing unused code.

// Fetch value of pull request SHA. If this is a PR, it will return SHA of HEAD commit of the PR, else "".
// If prSHA is not empty, that means we got an SHA, which is HEAD. Return this.
// Travis creates a merge commit for PR forks; use the real PR head instead.
if prSHA := os.Getenv("TRAVIS_PULL_REQUEST_SHA"); len(prSHA) > 0 {
Copy link

Choose a reason for hiding this comment

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

replace `len(prSHA) > 0` with `prSHA != ""`


It is not recommended to use len for empty string test.

}

// Handle special case for TravisCI
func getTravisCommit(topCommit string) (string, string, error) {
Copy link

Choose a reason for hiding this comment

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

func getTravisCommit is unused


It is recommended to keep the codebase clean by removing unused code.

)

// makeQuery makes a HTTP query with a specified body and returns the response
func makeQuery(url string, body []byte, bodyMimeType string, skipCertificateVerification bool) ([]byte, error) {
Copy link

Choose a reason for hiding this comment

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

func makeQuery is unused


It is recommended to keep the codebase clean by removing unused code.

Comment on lines +175 to +178
if err != nil {
// Config may still be corrupt from our test setup, but the PAT flow should have overwritten it
t.Logf("config load after PAT: %v (may be expected if overwrite failed)", err)
} else if cfg.Token != "dsp_fallback" {
Copy link

Choose a reason for hiding this comment

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

Test passes on error when it should fail


The test logic in TestLoginConfigLoadError is flawed. If cfgMgr.Load() returns an error after cmd.Execute(), it means the application failed to overwrite the corrupt configuration file with a valid one. The test currently logs this error and passes, masking a potential bug.

The test should instead fail explicitly if the configuration cannot be loaded after the login command has run. Replace the if err != nil block with a check that fails the test, for example using t.Fatalf().

- Remove unused git.go and query.go from command/report
- Fix flaky assertion in TestLoginConfigLoadError

// Mock client that returns a non-auth error
mock := graphqlclient.NewMockClient()
mock.QueryFunc = func(_ context.Context, query string, _ map[string]any, _ any) error {
Copy link

Choose a reason for hiding this comment

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

Function parameter `query` is declared but unused


The function assigned to mock.QueryFunc declares a parameter named query which is never used inside the function implementation. Unused parameters can confuse readers or indicate incomplete refactoring.
Rename or replace the unused query parameter with _ (underscore) to mark it explicitly as unused and improve code clarity and maintainability.

@jai-deepsource jai-deepsource merged commit 093ba87 into master Mar 1, 2026
3 of 5 checks passed
@jai-deepsource jai-deepsource deleted the v2-improvements branch March 1, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant