chore: Format and fix lints (#9336)

* make format

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Fix linting directives

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* make mockery

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Appease CI linter

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Appease CI linter

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
Thane Thomson
2022-08-30 12:28:46 -04:00
committed by GitHub
parent 7b40167f58
commit cceea4de22
87 changed files with 402 additions and 384 deletions
+3 -4
View File
@@ -1,4 +1,3 @@
// nolint: gosec
package app
import (
@@ -29,7 +28,7 @@ type SnapshotStore struct {
// NewSnapshotStore creates a new snapshot store.
func NewSnapshotStore(dir string) (*SnapshotStore, error) {
store := &SnapshotStore{dir: dir}
if err := os.MkdirAll(dir, 0755); err != nil {
if err := os.MkdirAll(dir, 0o755); err != nil {
return nil, err
}
if err := store.loadMetadata(); err != nil {
@@ -71,7 +70,7 @@ func (s *SnapshotStore) saveMetadata() error {
// save the file to a new file and move it to make saving atomic.
newFile := filepath.Join(s.dir, "metadata.json.new")
file := filepath.Join(s.dir, "metadata.json")
err = os.WriteFile(newFile, bz, 0644) // nolint: gosec
err = os.WriteFile(newFile, bz, 0o644) //nolint: gosec
if err != nil {
return err
}
@@ -92,7 +91,7 @@ func (s *SnapshotStore) Create(state *State) (abci.Snapshot, error) {
Hash: hashItems(state.Values),
Chunks: byteChunks(bz),
}
err = os.WriteFile(filepath.Join(s.dir, fmt.Sprintf("%v.json", state.Height)), bz, 0644)
err = os.WriteFile(filepath.Join(s.dir, fmt.Sprintf("%v.json", state.Height)), bz, 0o644) //nolint:gosec
if err != nil {
return abci.Snapshot{}, err
}
+5 -4
View File
@@ -1,4 +1,3 @@
//nolint: gosec
package app
import (
@@ -12,8 +11,10 @@ import (
"sync"
)
const stateFileName = "app_state.json"
const prevStateFileName = "prev_app_state.json"
const (
stateFileName = "app_state.json"
prevStateFileName = "prev_app_state.json"
)
// State is the application state.
type State struct {
@@ -81,7 +82,7 @@ func (s *State) save() error {
// We write the state to a separate file and move it to the destination, to
// make it atomic.
newFile := fmt.Sprintf("%v.new", s.currentFile)
err = os.WriteFile(newFile, bz, 0644)
err = os.WriteFile(newFile, bz, 0o644) //nolint:gosec
if err != nil {
return fmt.Errorf("failed to write state to %q: %w", s.currentFile, err)
}