Skip to content

Commit

Permalink
Fix source code linter checking
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
yeasy committed Mar 28, 2017
1 parent 51b7e85 commit 86e4684
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion common/config/standardvalues.go
Expand Up @@ -81,7 +81,7 @@ func (sv *standardValues) initializeProtosStruct(objValue reflect.Value) error {
case reflect.Ptr:
fieldPtr := objValue.Elem().Field(i)
if !fieldPtr.CanSet() {
return fmt.Errorf("Cannot set structure field %s (unexported?)", structField)
return fmt.Errorf("Cannot set structure field %s (unexported?)", structField.Name)
}
fieldPtr.Set(reflect.New(structField.Type.Elem()))
default:
Expand Down
3 changes: 2 additions & 1 deletion common/configtx/compare_test.go
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package configtx

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

cb "github.com/hyperledger/fabric/protos/common"
)

Expand Down
6 changes: 3 additions & 3 deletions common/configtx/configmap.go
Expand Up @@ -122,7 +122,7 @@ func recurseConfigMap(path string, configMap map[string]comparable) (*cb.ConfigG
}

if group.ConfigGroup == nil {
return nil, fmt.Errorf("ConfigGroup not found at group path", groupPath)
return nil, fmt.Errorf("ConfigGroup not found at group path: %s", groupPath)
}

for key, _ := range group.Groups {
Expand All @@ -140,7 +140,7 @@ func recurseConfigMap(path string, configMap map[string]comparable) (*cb.ConfigG
return nil, fmt.Errorf("Missing value at path: %s", valuePath)
}
if value.ConfigValue == nil {
return nil, fmt.Errorf("ConfigValue not found at value path", valuePath)
return nil, fmt.Errorf("ConfigValue not found at value path: %s", valuePath)
}
group.Values[key] = value.ConfigValue
}
Expand All @@ -152,7 +152,7 @@ func recurseConfigMap(path string, configMap map[string]comparable) (*cb.ConfigG
return nil, fmt.Errorf("Missing policy at path: %s", policyPath)
}
if policy.ConfigPolicy == nil {
return nil, fmt.Errorf("ConfigPolicy not found at policy path", policyPath)
return nil, fmt.Errorf("ConfigPolicy not found at policy path: %s", policyPath)
}
group.Policies[key] = policy.ConfigPolicy
}
Expand Down
3 changes: 2 additions & 1 deletion common/configtx/configmap_test.go
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package configtx

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

cb "github.com/hyperledger/fabric/protos/common"
)

Expand Down
2 changes: 1 addition & 1 deletion common/configtx/tool/configtxgen/main.go
Expand Up @@ -74,7 +74,7 @@ func doInspectBlock(inspectBlock string) error {
block := &cb.Block{}
err = proto.Unmarshal(data, block)
if err != nil {
fmt.Errorf("Error unmarshaling block: %s", err)
return fmt.Errorf("Error unmarshaling block: %s", err)
}

ctx, err := utils.ExtractEnvelope(block, 0)
Expand Down
2 changes: 1 addition & 1 deletion common/mocks/policies/policies.go
Expand Up @@ -76,4 +76,4 @@ func (m *Manager) GetPolicy(id string) (policies.Policy, bool) {
}
}
return m.Policy, m.Policy != nil
}
}
2 changes: 1 addition & 1 deletion common/policies/implicitmeta_test.go
Expand Up @@ -34,7 +34,7 @@ func (rp acceptPolicy) Evaluate(signedData []*cb.SignedData) error {
return nil
}

func TestimplicitMarshalError(t *testing.T) {
func TestImplicitMarshalError(t *testing.T) {
_, err := newImplicitMetaPolicy([]byte("GARBAGE"))
assert.Error(t, err, "Should have errored unmarshaling garbage")
}
Expand Down
14 changes: 13 additions & 1 deletion scripts/golinter.sh
Expand Up @@ -2,7 +2,19 @@

set -e

declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer" "./msp" "./gossip" "./bccsp")
declare -a arr=(
"./accesscontrol"
"./bccsp"
"./common"
"./core"
"./events"
"./examples"
"./gossip"
"./msp"
"./orderer"
"./peer"
"./protos"
)

for i in "${arr[@]}"
do
Expand Down

0 comments on commit 86e4684

Please sign in to comment.