-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style: orm module #15610
style: orm module #15610
Conversation
done |
I need to reduce this to orm-only again ....done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks in general good but I think a few things should be reverted:
- the codegen generating any instead of interfaces
- those arguments swapping.
- those methods renaming
|
||
golden.Assert(t, debugBuf.String(), "test_auto_inc.golden") | ||
checkEncodeDecodeEntries(t, table, store.IndexStoreReader()) | ||
} | ||
|
||
func runAutoIncrementScenario(t *testing.T, table ormtable.AutoIncrementTable, ctx context.Context) { | ||
// runAutoIncrementScenario runs a simple scenario with an auto-increment table. | ||
func runAutoIncrementScenario(ctx context.Context, t *testing.T, table ormtable.AutoIncrementTable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not for swapping argument of functions in style PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this complies with a linter rule, actually two of them:
- revive: context-as-argument
- thelper
@@ -99,7 +97,7 @@ func TestCompactUInt32(t *testing.T) { | |||
testEncodeDecode(1073741823, 4) | |||
testEncodeDecode(1073741824, 5) | |||
|
|||
// randomized tests | |||
// Randomized tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, is it a linter doing this? If so, which one? I think this has a too big impact to run such linter in the whole SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I have disabled it. Also I agree. Let me poke about on that.
@@ -4,12 +4,11 @@ import ( | |||
"fmt" | |||
"os" | |||
|
|||
ormv1 "cosmossdk.io/api/cosmos/orm/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep the import group
@@ -66,18 +66,14 @@ func (f fileGen) genStoreInterface(stores []*protogen.Message) { | |||
} | |||
|
|||
func (f fileGen) genStoreStruct(stores []*protogen.Message) { | |||
// struct | |||
// Struct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I don't like that comment changing linter 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok let me hunt it please.
@@ -5,19 +5,18 @@ import ( | |||
"strings" | |||
|
|||
"github.com/iancoleman/strcase" | |||
"google.golang.org/protobuf/reflect/protoreflect" | |||
) | |||
|
|||
func (t tableGen) genIndexKeys() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not change anything in the codegen in a linting PR, please.
Changing it to any makes the generated code require a specific minimum go version, while it wasn't the case before.
func (w *writer) F(format string, args ...interface{}) { | ||
_, err := w.Write([]byte(w.indentStr)) | ||
func (w *writer) F(format string, args ...any) { | ||
_, err := w.WriteString(w.indentStr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏾
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revive/use-any
"github.com/cosmos/cosmos-sdk/orm/internal/fieldnames" | ||
"github.com/cosmos/cosmos-sdk/orm/model/ormtable" | ||
"google.golang.org/protobuf/compiler/protogen" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the grouping was fine.
"github.com/cosmos/cosmos-sdk/orm/model/ormdb" | ||
"github.com/cosmos/cosmos-sdk/orm/model/ormtable" | ||
"google.golang.org/protobuf/proto" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grouping to be reverted.
} | ||
|
||
func (p primaryKeyIndex) get(backend ReadBackend, message proto.Message, values []protoreflect.Value) (found bool, err error) { | ||
func (p primaryKeyIndex) doGet(backend ReadBackend, message proto.Message, values []protoreflect.Value) (found bool, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revive/confusing-naming
Since this one seems to need some tlc, I will approach it again tomorrow |
Description
This PR works towards #15546
Per feedback, I've kept this to a single module -- in fact, just to make things simpler, I am going to remove the changes to all folders other than orm.
So, this lints just ORM, which is great. I've always found it confusing.
I think that some of the changes here to names of functions really do make it less confusing.
Lint Merge Order guide:
This will make reviews easier as following this merge order will recuce the size of diffs.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change