Skip to content

Commit

Permalink
cmd/go-metaflac: simplify control flow
Browse files Browse the repository at this point in the history
Fix issue reported by megacheck:

cmd/go-metaflac/metaflac.go:82:2: unnecessary nil check around range (megacheck)
	if blockNums != nil {
	^

Updates #25.
  • Loading branch information
mewmew committed May 27, 2018
1 parent 95b4b1d commit 6d39a79
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions cmd/go-metaflac/metaflac.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,8 @@ func list(path string) error {
return err
}

if blockNums != nil {
// Only list blocks specified in the "--block-number" command line flag.
for _, blockNum := range blockNums {
if blockNum == 0 {
listStreamInfo(stream.Info)
} else {
// strea.Blocks doesn't contain StreamInfo, therefore the blockNum
// is one less.
blockNum--
}
if blockNum < len(stream.Blocks) {
listBlock(stream.Blocks[blockNum], blockNum)
}
}
} else {
// List all blocks.
// List all blocks.
if blockNums == nil {
var isLast bool
if len(stream.Blocks) == 0 {
isLast = true
Expand All @@ -107,8 +93,22 @@ func list(path string) error {
blockNum--
listBlock(block, blockNum)
}
return nil
}

// Only list blocks specified in the "--block-number" command line flag.
for _, blockNum := range blockNums {
if blockNum == 0 {
listStreamInfo(stream.Info)
} else {
// strea.Blocks doesn't contain StreamInfo, therefore the blockNum
// is one less.
blockNum--
}
if blockNum < len(stream.Blocks) {
listBlock(stream.Blocks[blockNum], blockNum)
}
}
return nil
}

Expand Down

0 comments on commit 6d39a79

Please sign in to comment.