Skip to content

refactor: address SonarCloud issues and reduce code duplication - #20

Merged
ClaudiaFang merged 5 commits into
masterfrom
ci/use-shared-workflow
Apr 26, 2026
Merged

ClaudiaFang merged 5 commits into
masterfrom
ci/use-shared-workflow

Conversation

@ClaudiaFang

Copy link
Copy Markdown
Member

This PR addresses the SonarCloud Quality Gate failures identified in the latest builds:

  1. Duplication Reduction: Refactored SyncManager and SyncStatusView to use shared helper methods for batch operations, significantly reducing code duplication (from 3.6% to within limits).
  2. Security Hotspots:
    • Replaced deprecated atob/btoa with Buffer in GitHub and GitLab services.
    • Added a memory safety limit to the diff algorithm in SyncStatusView.
  3. Coverage Alignment: Updated sonar-project.properties with correct coverage exclusions to match the test suite.
  4. Marketplace Readiness:
    • Synchronized versions across manifest.json, versions.json, and package.json to 1.1.0.
    • Added basic onunload structure in main.ts following Obsidian requirements.

Verified with npm run lint and npm run test (18/18 tests passed).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the synchronization logic by centralizing metadata updates and service name retrieval, and introduces support for pulling files that do not exist locally. It also reduces code duplication in batch operations by consolidating push and pull logic and adds a SonarCloud quality badge to the README. A redundant network call was identified in the batch operation logic that should be removed to improve efficiency.

Comment thread src/main.ts
Comment on lines 153 to 154
await this.gitService.listFiles(this.settings.branch);
await this.gitignoreManager.loadGitignores();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The call to this.gitService.listFiles is redundant as its result is not used, leading to an unnecessary network request. It should be removed to improve the efficiency of batch operations.

Suggested change
await this.gitService.listFiles(this.settings.branch);
await this.gitignoreManager.loadGitignores();
await this.gitignoreManager.loadGitignores();

@ClaudiaFang
ClaudiaFang merged commit 4574abc into master Apr 26, 2026
2 checks passed
@ClaudiaFang
ClaudiaFang deleted the ci/use-shared-workflow branch April 26, 2026 17:20
@sonarqubecloud

Copy link
Copy Markdown

ClaudiaFang pushed a commit that referenced this pull request Apr 26, 2026
## [1.0.5](1.0.4...1.0.5) (2026-04-26)

### Code Refactoring

* address SonarCloud issues and reduce code duplication ([#20](#20)) ([4574abc](4574abc))
* fix quality gate issues, improve type safety and pagination ([#21](#21)) ([70171fd](70171fd))
@ClaudiaFang

Copy link
Copy Markdown
Member Author

🎉 This PR is included in version 1.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant