Skip to content

Commit

Permalink
Linter pass (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
philtay authored and bmoffatt committed Jul 5, 2019
1 parent 4b515f5 commit e7b076e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
5 changes: 2 additions & 3 deletions cmd/build-lambda-zip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {

app.Action = func(c *cli.Context) error {
if !c.Args().Present() {
return errors.New("No input provided")
return errors.New("no input provided")
}

inputExe := c.Args().First()
Expand All @@ -35,7 +35,7 @@ func main() {
}

if err := compressExeAndArgs(outputZip, inputExe, c.Args().Tail()); err != nil {
return fmt.Errorf("Failed to compress file: %v", err)
return fmt.Errorf("failed to compress file: %v", err)
}
return nil
}
Expand Down Expand Up @@ -71,7 +71,6 @@ func compressExeAndArgs(outZipPath string, exePath string, args []string) error
if closeErr != nil {
fmt.Fprintf(os.Stderr, "Failed to close zip file: %v\n", closeErr)
}
return
}()

zipWriter := zip.NewWriter(zipFile)
Expand Down
4 changes: 2 additions & 2 deletions events/attributevalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ func Test_DynamoDBAttributeValue_NewAttribute(t *testing.T) {
assert.Equal(t, true, av.Boolean())
}
{
av := NewBinarySetAttribute([][]byte{[]byte{1, 2, 3}})
av := NewBinarySetAttribute([][]byte{{1, 2, 3}})
assert.Equal(t, DataTypeBinarySet, av.DataType())
assert.Equal(t, [][]byte{[]byte{1, 2, 3}}, av.BinarySet())
assert.Equal(t, [][]byte{{1, 2, 3}}, av.BinarySet())
}
{
av := NewListAttribute([]DynamoDBAttributeValue{
Expand Down
7 changes: 3 additions & 4 deletions events/cloudwatch_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ func (c CloudwatchLogsRawData) Parse() (d CloudwatchLogsData, err error) {
}

zr, err := gzip.NewReader(bytes.NewBuffer(data))
defer zr.Close()
if err != nil {
return
}
defer zr.Close()

buf := &bytes.Buffer{}
buf.ReadFrom(zr)
dec := json.NewDecoder(zr)
err = dec.Decode(&d)

err = json.Unmarshal(buf.Bytes(), &d)
return
}

Expand Down
4 changes: 2 additions & 2 deletions events/cognito.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CognitoEventUserPoolsPostConfirmation struct {
}

// CognitoEventUserPoolsPreTokenGen is sent by AWS Cognito User Pools when a user attempts to retrieve
// credentials, allowing a Lambda to perform insert, supress or override claims
// credentials, allowing a Lambda to perform insert, suppress or override claims
type CognitoEventUserPoolsPreTokenGen struct {
CognitoEventUserPoolsHeader
Request CognitoEventUserPoolsPreTokenGenRequest `json:"request"`
Expand Down Expand Up @@ -133,7 +133,7 @@ type CognitoEventUserPoolsMigrateUserResponse struct {
ForceAliasCreation bool `json:"forceAliasCreation"`
}

// ClaimsOverrideDetails allows lambda to add, supress or override claims in the token
// ClaimsOverrideDetails allows lambda to add, suppress or override claims in the token
type ClaimsOverrideDetails struct {
GroupOverrideDetails GroupConfiguration `json:"groupOverrideDetails"`
ClaimsToAddOrOverride map[string]string `json:"claimsToAddOrOverride"`
Expand Down
2 changes: 0 additions & 2 deletions events/firehose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func testFirehoseResponseMarshaling(t *testing.T) {
}

func testMarshaling(t *testing.T, jsonFile string) {

// 1. read JSON from file
inputJson := test.ReadJSONFromFile(t, jsonFile)

Expand All @@ -41,7 +40,6 @@ func testMarshaling(t *testing.T, jsonFile string) {
}

func TestSampleTransformation(t *testing.T) {

inputJson := test.ReadJSONFromFile(t, "./testdata/kinesis-firehose-event.json")

// de-serialize into Go object
Expand Down
9 changes: 6 additions & 3 deletions lambda/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ func validateArguments(handler reflect.Type) (bool, error) {

func validateReturns(handler reflect.Type) error {
errorType := reflect.TypeOf((*error)(nil)).Elem()
if handler.NumOut() > 2 {

switch n := handler.NumOut(); {
case n > 2:
return fmt.Errorf("handler may not return more than two values")
} else if handler.NumOut() > 1 {
case n > 1:
if !handler.Out(1).Implements(errorType) {
return fmt.Errorf("handler returns two values, but the second does not implement error")
}
} else if handler.NumOut() == 1 {
case n == 1:
if !handler.Out(0).Implements(errorType) {
return fmt.Errorf("handler returns a single value, but it does not implement error")
}
}

return nil
}

Expand Down

0 comments on commit e7b076e

Please sign in to comment.