Skip to content

Commit 86e4684

Browse files
committed
Fix source code linter checking
Existing `make linter` will miss the accesscontrol and common source code directory. This patchset fix the missing and the linter checking problem in the missed paths. This patchset fixes FAB-2902. https://jira.hyperledger.org/browse/FAB-2902 Change-Id: I504b856441642a0e12ed3fc7d1bb20b90cd1358c Signed-off-by: Baohua Yang <baohyang@cn.ibm.com>
1 parent 51b7e85 commit 86e4684

File tree

8 files changed

+24
-10
lines changed

8 files changed

+24
-10
lines changed

common/config/standardvalues.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (sv *standardValues) initializeProtosStruct(objValue reflect.Value) error {
8181
case reflect.Ptr:
8282
fieldPtr := objValue.Elem().Field(i)
8383
if !fieldPtr.CanSet() {
84-
return fmt.Errorf("Cannot set structure field %s (unexported?)", structField)
84+
return fmt.Errorf("Cannot set structure field %s (unexported?)", structField.Name)
8585
}
8686
fieldPtr.Set(reflect.New(structField.Type.Elem()))
8787
default:

common/configtx/compare_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package configtx
1818

1919
import (
20-
"github.com/stretchr/testify/assert"
2120
"testing"
2221

22+
"github.com/stretchr/testify/assert"
23+
2324
cb "github.com/hyperledger/fabric/protos/common"
2425
)
2526

common/configtx/configmap.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func recurseConfigMap(path string, configMap map[string]comparable) (*cb.ConfigG
122122
}
123123

124124
if group.ConfigGroup == nil {
125-
return nil, fmt.Errorf("ConfigGroup not found at group path", groupPath)
125+
return nil, fmt.Errorf("ConfigGroup not found at group path: %s", groupPath)
126126
}
127127

128128
for key, _ := range group.Groups {
@@ -140,7 +140,7 @@ func recurseConfigMap(path string, configMap map[string]comparable) (*cb.ConfigG
140140
return nil, fmt.Errorf("Missing value at path: %s", valuePath)
141141
}
142142
if value.ConfigValue == nil {
143-
return nil, fmt.Errorf("ConfigValue not found at value path", valuePath)
143+
return nil, fmt.Errorf("ConfigValue not found at value path: %s", valuePath)
144144
}
145145
group.Values[key] = value.ConfigValue
146146
}
@@ -152,7 +152,7 @@ func recurseConfigMap(path string, configMap map[string]comparable) (*cb.ConfigG
152152
return nil, fmt.Errorf("Missing policy at path: %s", policyPath)
153153
}
154154
if policy.ConfigPolicy == nil {
155-
return nil, fmt.Errorf("ConfigPolicy not found at policy path", policyPath)
155+
return nil, fmt.Errorf("ConfigPolicy not found at policy path: %s", policyPath)
156156
}
157157
group.Policies[key] = policy.ConfigPolicy
158158
}

common/configtx/configmap_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package configtx
1818

1919
import (
20-
"github.com/stretchr/testify/assert"
2120
"testing"
2221

22+
"github.com/stretchr/testify/assert"
23+
2324
cb "github.com/hyperledger/fabric/protos/common"
2425
)
2526

common/configtx/tool/configtxgen/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func doInspectBlock(inspectBlock string) error {
7474
block := &cb.Block{}
7575
err = proto.Unmarshal(data, block)
7676
if err != nil {
77-
fmt.Errorf("Error unmarshaling block: %s", err)
77+
return fmt.Errorf("Error unmarshaling block: %s", err)
7878
}
7979

8080
ctx, err := utils.ExtractEnvelope(block, 0)

common/mocks/policies/policies.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ func (m *Manager) GetPolicy(id string) (policies.Policy, bool) {
7676
}
7777
}
7878
return m.Policy, m.Policy != nil
79-
}
79+
}

common/policies/implicitmeta_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (rp acceptPolicy) Evaluate(signedData []*cb.SignedData) error {
3434
return nil
3535
}
3636

37-
func TestimplicitMarshalError(t *testing.T) {
37+
func TestImplicitMarshalError(t *testing.T) {
3838
_, err := newImplicitMetaPolicy([]byte("GARBAGE"))
3939
assert.Error(t, err, "Should have errored unmarshaling garbage")
4040
}

scripts/golinter.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22

33
set -e
44

5-
declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer" "./msp" "./gossip" "./bccsp")
5+
declare -a arr=(
6+
"./accesscontrol"
7+
"./bccsp"
8+
"./common"
9+
"./core"
10+
"./events"
11+
"./examples"
12+
"./gossip"
13+
"./msp"
14+
"./orderer"
15+
"./peer"
16+
"./protos"
17+
)
618

719
for i in "${arr[@]}"
820
do

0 commit comments

Comments
 (0)