Skip to content

Commit 16f3c31

Browse files
roveneliahkaralabe
authored andcommitted
signer: fix golint errors (#16653)
* signer/*: golint fixes Specifically naming and comment formatting for documentation * signer/*: fixed naming error crashing build * signer/*: corrected error * signer/core: fix tiny error whitespace * signer/rules: fix test refactor
1 parent 5b3af4c commit 16f3c31

File tree

8 files changed

+78
-79
lines changed

8 files changed

+78
-79
lines changed

signer/core/abihelper.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,12 @@ func parseCallData(calldata []byte, abidata string) (*decodedCallData, error) {
9494
for n, argument := range method.Inputs {
9595
if err != nil {
9696
return nil, fmt.Errorf("Failed to decode argument %d (signature %v): %v", n, method.Sig(), err)
97-
} else {
98-
decodedArg := decodedArgument{
99-
soltype: argument,
100-
value: v[n],
101-
}
102-
decoded.inputs = append(decoded.inputs, decodedArg)
10397
}
98+
decodedArg := decodedArgument{
99+
soltype: argument,
100+
value: v[n],
101+
}
102+
decoded.inputs = append(decoded.inputs, decodedArg)
104103
}
105104

106105
// We're finished decoding the data. At this point, we encode the decoded data to see if it matches with the
@@ -240,7 +239,7 @@ func (db *AbiDb) saveCustomAbi(selector, signature string) error {
240239
return err
241240
}
242241

243-
// Adds a signature to the database, if custom database saving is enabled.
242+
// AddSignature to the database, if custom database saving is enabled.
244243
// OBS: This method does _not_ validate the correctness of the data,
245244
// it is assumed that the caller has already done so
246245
func (db *AbiDb) AddSignature(selector string, data []byte) error {

signer/core/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ func (api *SignerAPI) Export(ctx context.Context, addr common.Address) (json.Raw
474474
return ioutil.ReadFile(wallet.URL().Path)
475475
}
476476

477-
// Imports tries to import the given keyJSON in the local keystore. The keyJSON data is expected to be
477+
// Import tries to import the given keyJSON in the local keystore. The keyJSON data is expected to be
478478
// in web3 keystore format. It will decrypt the keyJSON with the given passphrase and on successful
479479
// decryption it will encrypt the key with the given newPassphrase and store it in the keystore.
480480
func (api *SignerAPI) Import(ctx context.Context, keyJSON json.RawMessage) (Account, error) {

signer/core/cliui.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
16+
1617
package core
1718

1819
import (

signer/core/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ type SendTxArgs struct {
7373
Input *hexutil.Bytes `json:"input"`
7474
}
7575

76-
func (t SendTxArgs) String() string {
77-
s, err := json.Marshal(t)
76+
func (args SendTxArgs) String() string {
77+
s, err := json.Marshal(args)
7878
if err == nil {
7979
return string(s)
8080
}

signer/core/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (v *Validator) validate(msgs *ValidationMessages, txargs *SendTxArgs, metho
128128
if len(data) == 0 {
129129
if txargs.Value.ToInt().Cmp(big.NewInt(0)) > 0 {
130130
// Sending ether into black hole
131-
return errors.New(`Tx will create contract with value but empty code!`)
131+
return errors.New("Tx will create contract with value but empty code!")
132132
}
133133
// No value submitted at least
134134
msgs.crit("Tx will create contract with empty code!")

signer/rules/rules.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ func consoleOutput(call otto.FunctionCall) otto.Value {
4646
return otto.Value{}
4747
}
4848

49-
// rulesetUi provides an implementation of SignerUI that evaluates a javascript
49+
// rulesetUI provides an implementation of SignerUI that evaluates a javascript
5050
// file for each defined UI-method
51-
type rulesetUi struct {
51+
type rulesetUI struct {
5252
next core.SignerUI // The next handler, for manual processing
5353
storage storage.Storage
5454
credentials storage.Storage
5555
jsRules string // The rules to use
5656
}
5757

58-
func NewRuleEvaluator(next core.SignerUI, jsbackend, credentialsBackend storage.Storage) (*rulesetUi, error) {
59-
c := &rulesetUi{
58+
func NewRuleEvaluator(next core.SignerUI, jsbackend, credentialsBackend storage.Storage) (*rulesetUI, error) {
59+
c := &rulesetUI{
6060
next: next,
6161
storage: jsbackend,
6262
credentials: credentialsBackend,
@@ -66,11 +66,11 @@ func NewRuleEvaluator(next core.SignerUI, jsbackend, credentialsBackend storage.
6666
return c, nil
6767
}
6868

69-
func (r *rulesetUi) Init(javascriptRules string) error {
69+
func (r *rulesetUI) Init(javascriptRules string) error {
7070
r.jsRules = javascriptRules
7171
return nil
7272
}
73-
func (r *rulesetUi) execute(jsfunc string, jsarg interface{}) (otto.Value, error) {
73+
func (r *rulesetUI) execute(jsfunc string, jsarg interface{}) (otto.Value, error) {
7474

7575
// Instantiate a fresh vm engine every time
7676
vm := otto.New()
@@ -115,7 +115,7 @@ func (r *rulesetUi) execute(jsfunc string, jsarg interface{}) (otto.Value, error
115115
return vm.Run(call)
116116
}
117117

118-
func (r *rulesetUi) checkApproval(jsfunc string, jsarg []byte, err error) (bool, error) {
118+
func (r *rulesetUI) checkApproval(jsfunc string, jsarg []byte, err error) (bool, error) {
119119
if err != nil {
120120
return false, err
121121
}
@@ -139,7 +139,7 @@ func (r *rulesetUi) checkApproval(jsfunc string, jsarg []byte, err error) (bool,
139139
return false, fmt.Errorf("Unknown response")
140140
}
141141

142-
func (r *rulesetUi) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse, error) {
142+
func (r *rulesetUI) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse, error) {
143143
jsonreq, err := json.Marshal(request)
144144
approved, err := r.checkApproval("ApproveTx", jsonreq, err)
145145
if err != nil {
@@ -158,11 +158,11 @@ func (r *rulesetUi) ApproveTx(request *core.SignTxRequest) (core.SignTxResponse,
158158
return core.SignTxResponse{Approved: false}, err
159159
}
160160

161-
func (r *rulesetUi) lookupPassword(address common.Address) string {
161+
func (r *rulesetUI) lookupPassword(address common.Address) string {
162162
return r.credentials.Get(strings.ToLower(address.String()))
163163
}
164164

165-
func (r *rulesetUi) ApproveSignData(request *core.SignDataRequest) (core.SignDataResponse, error) {
165+
func (r *rulesetUI) ApproveSignData(request *core.SignDataRequest) (core.SignDataResponse, error) {
166166
jsonreq, err := json.Marshal(request)
167167
approved, err := r.checkApproval("ApproveSignData", jsonreq, err)
168168
if err != nil {
@@ -175,7 +175,7 @@ func (r *rulesetUi) ApproveSignData(request *core.SignDataRequest) (core.SignDat
175175
return core.SignDataResponse{Approved: false, Password: ""}, err
176176
}
177177

178-
func (r *rulesetUi) ApproveExport(request *core.ExportRequest) (core.ExportResponse, error) {
178+
func (r *rulesetUI) ApproveExport(request *core.ExportRequest) (core.ExportResponse, error) {
179179
jsonreq, err := json.Marshal(request)
180180
approved, err := r.checkApproval("ApproveExport", jsonreq, err)
181181
if err != nil {
@@ -188,13 +188,13 @@ func (r *rulesetUi) ApproveExport(request *core.ExportRequest) (core.ExportRespo
188188
return core.ExportResponse{Approved: false}, err
189189
}
190190

191-
func (r *rulesetUi) ApproveImport(request *core.ImportRequest) (core.ImportResponse, error) {
191+
func (r *rulesetUI) ApproveImport(request *core.ImportRequest) (core.ImportResponse, error) {
192192
// This cannot be handled by rules, requires setting a password
193193
// dispatch to next
194194
return r.next.ApproveImport(request)
195195
}
196196

197-
func (r *rulesetUi) ApproveListing(request *core.ListRequest) (core.ListResponse, error) {
197+
func (r *rulesetUI) ApproveListing(request *core.ListRequest) (core.ListResponse, error) {
198198
jsonreq, err := json.Marshal(request)
199199
approved, err := r.checkApproval("ApproveListing", jsonreq, err)
200200
if err != nil {
@@ -207,22 +207,22 @@ func (r *rulesetUi) ApproveListing(request *core.ListRequest) (core.ListResponse
207207
return core.ListResponse{}, err
208208
}
209209

210-
func (r *rulesetUi) ApproveNewAccount(request *core.NewAccountRequest) (core.NewAccountResponse, error) {
210+
func (r *rulesetUI) ApproveNewAccount(request *core.NewAccountRequest) (core.NewAccountResponse, error) {
211211
// This cannot be handled by rules, requires setting a password
212212
// dispatch to next
213213
return r.next.ApproveNewAccount(request)
214214
}
215215

216-
func (r *rulesetUi) ShowError(message string) {
216+
func (r *rulesetUI) ShowError(message string) {
217217
log.Error(message)
218218
r.next.ShowError(message)
219219
}
220220

221-
func (r *rulesetUi) ShowInfo(message string) {
221+
func (r *rulesetUI) ShowInfo(message string) {
222222
log.Info(message)
223223
r.next.ShowInfo(message)
224224
}
225-
func (r *rulesetUi) OnSignerStartup(info core.StartupInfo) {
225+
func (r *rulesetUI) OnSignerStartup(info core.StartupInfo) {
226226
jsonInfo, err := json.Marshal(info)
227227
if err != nil {
228228
log.Warn("failed marshalling data", "data", info)
@@ -235,7 +235,7 @@ func (r *rulesetUi) OnSignerStartup(info core.StartupInfo) {
235235
}
236236
}
237237

238-
func (r *rulesetUi) OnApprovedTx(tx ethapi.SignTransactionResult) {
238+
func (r *rulesetUI) OnApprovedTx(tx ethapi.SignTransactionResult) {
239239
jsonTx, err := json.Marshal(tx)
240240
if err != nil {
241241
log.Warn("failed marshalling transaction", "tx", tx)

0 commit comments

Comments
 (0)