Skip to content

Conversation

@gmegidish
Copy link
Member

@gmegidish gmegidish commented Dec 18, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new "doctor" CLI command to diagnose your development environment, verifying Android SDK, Xcode installation, system configuration, and displaying relevant tool versions and OS details.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

Introduces a new "doctor" CLI subcommand that performs system diagnostics. Adds a GetVersion() function to retrieve the module version and creates a commands/doctor.go file with DoctorCommand and DoctorInfo struct to collect environment diagnostic information including OS details, Android SDK paths, and Xcode configuration.

Changes

Cohort / File(s) Summary
CLI doctor subcommand
cli/doctor.go, cli/root.go
Implements doctor CLI command via Cobra that invokes DoctorCommand with version parameter; adds GetVersion() function to return current module version
System diagnostics implementation
commands/doctor.go
Introduces DoctorInfo struct with fields for version and environment details; implements DoctorCommand function to collect OS version, Android SDK paths, ADB version, Xcode paths, and developer tools security status

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a new 'doctor' subcommand to mobilecli for system diagnostics and troubleshooting.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-doctor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
cli/doctor.go (1)

14-21: Simplify error formatting.

The fmt.Errorf("%s", response.Error) pattern is redundant when response.Error is already a string.

🔎 Apply this diff to simplify:
 	RunE: func(cmd *cobra.Command, args []string) error {
 		response := commands.DoctorCommand(GetVersion())
 		printJson(response)
 		if response.Status == "error" {
-			return fmt.Errorf("%s", response.Error)
+			return fmt.Errorf(response.Error)
 		}
 		return nil
 	},
commands/doctor.go (1)

129-170: Clarify the distinction and consider consolidating.

Both getXcodePath() and getXcodeCLIToolsPath() execute the same xcode-select -p command:

  • getXcodePath() filters for paths containing "Xcode.app" (full Xcode installation)
  • getXcodeCLIToolsPath() returns any valid path (including standalone Command Line Tools)

This creates two concerns:

  1. The distinction between these functions isn't immediately clear from their names
  2. The xcode-select -p command is executed twice unnecessarily

Consider consolidating the logic or documenting the intended difference more clearly.

🔎 View suggested refactor:
+func getXcodeSelectPath() string {
+	if runtime.GOOS != "darwin" {
+		return ""
+	}
+
+	cmd := exec.Command("xcode-select", "-p")
+	output, err := cmd.CombinedOutput()
+	if err != nil {
+		return ""
+	}
+
+	path := strings.TrimSpace(string(output))
+	if _, err := os.Stat(path); err == nil {
+		return path
+	}
+	return ""
+}
+
 func getXcodePath() string {
-	if runtime.GOOS != "darwin" {
-		return ""
-	}
-
-	// check if Xcode.app is installed
-	cmd := exec.Command("xcode-select", "-p")
-	output, err := cmd.CombinedOutput()
-	if err != nil {
-		return ""
-	}
-
-	path := strings.TrimSpace(string(output))
-
+	path := getXcodeSelectPath()
 	// check if this is the full Xcode.app path
 	if strings.Contains(path, "Xcode.app") {
 		return path
 	}
 
 	return ""
 }
 
 func getXcodeCLIToolsPath() string {
-	if runtime.GOOS != "darwin" {
-		return ""
-	}
-
-	cmd := exec.Command("xcode-select", "-p")
-	output, err := cmd.CombinedOutput()
-	if err != nil {
-		return ""
-	}
-
-	path := strings.TrimSpace(string(output))
-
-	// verify the path exists
-	if _, err := os.Stat(path); err == nil {
-		return path
-	}
-
-	return ""
+	return getXcodeSelectPath()
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b09091 and 4d0f76f.

📒 Files selected for processing (3)
  • cli/doctor.go (1 hunks)
  • cli/root.go (1 hunks)
  • commands/doctor.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
cli/doctor.go (2)
commands/doctor.go (1)
  • DoctorCommand (226-249)
cli/root.go (1)
  • GetVersion (132-134)
commands/doctor.go (1)
commands/commands.go (2)
  • CommandResponse (11-15)
  • NewSuccessResponse (18-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: lint
🔇 Additional comments (10)
cli/root.go (1)

131-134: LGTM!

The GetVersion() function correctly exposes the internal version constant for use by the doctor command.

cli/doctor.go (1)

24-26: LGTM!

The command registration follows standard Cobra patterns.

commands/doctor.go (8)

11-22: LGTM!

The DoctorInfo struct is well-structured with appropriate JSON tags, and correctly uses a pointer type for the optional boolean field.


24-62: LGTM!

The function correctly checks ANDROID_HOME and falls back to platform-specific default locations, with proper path validation.


64-84: LGTM!

The function correctly locates adb from the Android SDK or system PATH, with appropriate Windows executable suffix handling.


86-105: LGTM!

The function follows the same pattern as getAdbPath(), correctly locating the emulator binary.


107-127: LGTM!

The function appropriately handles the adb version command output and gracefully returns empty strings on errors, which is suitable for diagnostic purposes.


172-189: LGTM!

The function appropriately checks DevToolsSecurity status on macOS and uses a pointer to bool for proper optional handling in JSON serialization.


191-223: LGTM!

The function correctly handles OS version retrieval for Darwin, Windows, and Linux using platform-appropriate methods.


225-249: LGTM!

The DoctorCommand() function properly aggregates diagnostic information with appropriate platform-specific conditional logic, and returns a well-structured response.

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.

2 participants