mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
refactor: cleanup dead code and turn on dead code detection in CI (#515)
* cleanup dead code. Signed-off-by: Kai Xia <kaix+github@fastmail.com> * add these two back with flag. Signed-off-by: Kai Xia <kaix+github@fastmail.com> * fix ci Signed-off-by: Kai Xia <kaix+github@fastmail.com> * remove this confusing line Signed-off-by: Kai Xia <kaix+github@fastmail.com> * make fmt Signed-off-by: Kai Xia <kaix+github@fastmail.com> * remove unused method. picked up by golangci-lint run Signed-off-by: Kai Xia <kaix+github@fastmail.com> --------- Signed-off-by: Kai Xia <kaix+github@fastmail.com>
This commit is contained in:
@@ -117,13 +117,19 @@ func (t *I2CTool) detect() *ToolResult {
|
||||
return SilentResult(fmt.Sprintf("Found %d I2C bus(es):\n%s", len(buses), string(result)))
|
||||
}
|
||||
|
||||
// Helper functions for I2C operations (used by platform-specific implementations)
|
||||
|
||||
// isValidBusID checks that a bus identifier is a simple number (prevents path injection)
|
||||
//
|
||||
//nolint:unused // Used by i2c_linux.go
|
||||
func isValidBusID(id string) bool {
|
||||
matched, _ := regexp.MatchString(`^\d+$`, id)
|
||||
return matched
|
||||
}
|
||||
|
||||
// parseI2CAddress extracts and validates an I2C address from args
|
||||
//
|
||||
//nolint:unused // Used by i2c_linux.go
|
||||
func parseI2CAddress(args map[string]any) (int, *ToolResult) {
|
||||
addrFloat, ok := args["address"].(float64)
|
||||
if !ok {
|
||||
@@ -137,6 +143,8 @@ func parseI2CAddress(args map[string]any) (int, *ToolResult) {
|
||||
}
|
||||
|
||||
// parseI2CBus extracts and validates an I2C bus from args
|
||||
//
|
||||
//nolint:unused // Used by i2c_linux.go
|
||||
func parseI2CBus(args map[string]any) (string, *ToolResult) {
|
||||
bus, ok := args["bus"].(string)
|
||||
if !ok || bus == "" {
|
||||
|
||||
@@ -119,7 +119,11 @@ func (t *SPITool) list() *ToolResult {
|
||||
return SilentResult(fmt.Sprintf("Found %d SPI device(s):\n%s", len(devices), string(result)))
|
||||
}
|
||||
|
||||
// Helper function for SPI operations (used by platform-specific implementations)
|
||||
|
||||
// parseSPIArgs extracts and validates common SPI parameters
|
||||
//
|
||||
//nolint:unused // Used by spi_linux.go
|
||||
func parseSPIArgs(args map[string]any) (device string, speed uint32, mode uint8, bits uint8, errMsg string) {
|
||||
dev, ok := args["device"].(string)
|
||||
if !ok || dev == "" {
|
||||
|
||||
Reference in New Issue
Block a user