Kaynağa Gözat

enable receiver-nameing check

Signed-off-by: yisaer <disxiaofei@163.com>
yisaer 2 yıl önce
ebeveyn
işleme
c065db089c

+ 12 - 12
internal/io/mqtt/mqtt_type.go

@@ -42,25 +42,25 @@ type modelVersion interface {
 func modelFactory(_ string) modelVersion {
 	return new(deviceModel)
 }
-func (this *property) getName() string {
-	return this.Name
+func (p *property) getName() string {
+	return p.Name
 }
-func (this *property) getDataType() string {
-	return this.DataType
+func (p *property) getDataType() string {
+	return p.DataType
 }
-func (this *device) getName() string {
-	return this.Name
+func (d *device) getName() string {
+	return d.Name
 }
-func (this *device) findDataType(name string) string {
-	for _, v := range this.Properties {
+func (d *device) findDataType(name string) string {
+	for _, v := range d.Properties {
 		if strings.EqualFold(v.getName(), name) {
 			return v.getDataType()
 		}
 	}
 	return ""
 }
-func (this *deviceModel) findDataType(deviceId, dataName string) string {
-	for _, v := range this.Devices {
+func (dm *deviceModel) findDataType(deviceId, dataName string) string {
+	for _, v := range dm.Devices {
 		if strings.EqualFold(v.getName(), deviceId) {
 			return v.findDataType(dataName)
 		}
@@ -152,7 +152,7 @@ func topicToDeviceid(topic string) string {
 	}
 	return sliStr[3]
 }
-func (this *deviceModel) checkType(m map[string]interface{}, topic string) []string {
+func (dm *deviceModel) checkType(m map[string]interface{}, topic string) []string {
 	var sliErr []string
 	strErr := ""
 	for k, v := range m {
@@ -161,7 +161,7 @@ func (this *deviceModel) checkType(m map[string]interface{}, topic string) []str
 			sliErr = append(sliErr, fmt.Sprintf("not find deviceid : %s", topic))
 			continue
 		}
-		modelType := this.findDataType(deviceid, k)
+		modelType := dm.findDataType(deviceid, k)
 		if 0 == len(modelType) {
 			continue
 		}

+ 2 - 2
internal/service/external_service_rule_test.go

@@ -529,8 +529,8 @@ func jsonOut(w http.ResponseWriter, err error, out interface{}) {
 
 type Resolver map[string]reflect.Value
 
-func (self Resolver) Resolve(name string, _ []reflect.Value) (reflect.Value, error) {
-	return self[name], nil
+func (r Resolver) Resolve(name string, _ []reflect.Value) (reflect.Value, error) {
+	return r[name], nil
 }
 
 func SayHello(name string) map[string]interface{} {

+ 7 - 7
internal/xsql/manager.go

@@ -31,21 +31,21 @@ type ParseTree struct {
 	Keys     []string
 }
 
-func (t *ParseTree) Handle(lit string, fn func(*Parser) (ast.Statement, error)) {
+func (pt *ParseTree) Handle(lit string, fn func(*Parser) (ast.Statement, error)) {
 	// Verify that there is no conflict for this token in this parse tree.
-	if _, conflict := t.Tokens[lit]; conflict {
+	if _, conflict := pt.Tokens[lit]; conflict {
 		panic(fmt.Sprintf("conflict for token %s", lit))
 	}
 
-	if _, conflict := t.Handlers[lit]; conflict {
+	if _, conflict := pt.Handlers[lit]; conflict {
 		panic(fmt.Sprintf("conflict for token %s", lit))
 	}
 
-	if t.Handlers == nil {
-		t.Handlers = make(map[string]func(*Parser) (ast.Statement, error))
+	if pt.Handlers == nil {
+		pt.Handlers = make(map[string]func(*Parser) (ast.Statement, error))
 	}
-	t.Handlers[lit] = fn
-	t.Keys = append(t.Keys, lit)
+	pt.Handlers[lit] = fn
+	pt.Keys = append(pt.Keys, lit)
 }
 
 func (pt *ParseTree) Parse(p *Parser) (ast.Statement, error) {

+ 1 - 1
pkg/ast/expr.go

@@ -162,7 +162,7 @@ type BinaryExpr struct {
 	RHS Expr
 }
 
-func (fe *BinaryExpr) expr() {}
+func (be *BinaryExpr) expr() {}
 func (be *BinaryExpr) node() {}
 
 type WhenClause struct {

+ 1 - 1
tools/check/revive.toml

@@ -15,7 +15,7 @@ warningCode = -1
 #[rule.var-naming]
 #[rule.package-comments]
 [rule.range]
-#[rule.receiver-naming]
+[rule.receiver-naming]
 #[rule.indent-error-flow]
 #[rule.superfluous-else]
 [rule.modifies-parameter]