-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
5b317da
to
58e2ddf
Compare
@JackyChiu Thanks, I'll review and add some feedback soon. In the meantime, can you look at #302 and see if you can write a function that could help with that issue as well? And for a test repo, you can create one in your account and I'll fork it from you later. EDIT: updated the link to the other issue. |
@darkowlzz Thanks! It's the holidays, so no rush at all! |
codeclimate is giving a error for the test functions max lines of code and cognitive complexity. Does it make sense to have these rules applied to tests? |
cmd/dep/status.go
Outdated
@@ -793,12 +793,23 @@ func collectConstraints(ctx *dep.Ctx, p *dep.Project, sm gps.SourceManager) (con | |||
// Get project constraints. | |||
pc := manifest.DependencyConstraints() | |||
|
|||
imports, err := projectImports(sm, proj) | |||
if err != nil { | |||
errCh <- errors.Wrapf(err, "error listing imports used in %s", proj.Ident().ProjectRoot) |
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.
If we send this error to the existing error channel, we might end up overflowing the error channel. I would recommend creating another error channel for collecting these errors separately, similar to errListPkgCh
and errListVerCh
in runStatusAll()
.
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 probably won't need to error after refactoring for the use case above 😄
cmd/dep/status.go
Outdated
@@ -793,12 +793,23 @@ func collectConstraints(ctx *dep.Ctx, p *dep.Project, sm gps.SourceManager) (con | |||
// Get project constraints. | |||
pc := manifest.DependencyConstraints() | |||
|
|||
imports, err := projectImports(sm, proj) |
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.
If I understand this correctly, imports
contains all the imports of proj
right? Not the root project?
Applicable/working constraints are in respect to the root project, p
. That's why getApplicableConstraints()
uses rootdata
to walk through all the import paths.
Correct me if I'm not seeing it the wrong way 🙂
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.
Opps! My bad, I misunderstood. This makes it simpler though!
I also looked the issue you referred me to, and it does look like a function could be written to satisfy both issues. Which file would the best placement be for it?
cmd/dep/status_test.go
Outdated
lock: dep.Lock{ | ||
P: []gps.LockedProject{ | ||
gps.NewLockedProject( | ||
gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/JackyChiu/deptest")}, |
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 name the test project something relevant to the test, which would help us recall and refer to it easily. Maybe use words like applicable
, constraints
, or anything that you think would be accurate. 😊
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.
Sounds good
@JackyChiu ignore those codeclimate errors for now. Those errors started showing up a few weeks back. Refer https://twitter.com/sdboyer/status/939159860159111169 , not the exact error but I'm sure they have the same origin. |
added tests for projectImports collect applicable constraints only test update term used in err msg break up import functions
applicable constrain fixtures
6c8a51c
to
cac9c6b
Compare
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 looks correct to me. But I would like to wait and ponder on it a bit and maybe have another review.
cmd/dep/status_test.go
Outdated
@@ -305,6 +305,7 @@ func TestCollectConstraints(t *testing.T) { | |||
ver1, _ := gps.NewSemverConstraintIC("v1.0.0") | |||
ver08, _ := gps.NewSemverConstraintIC("v0.8.0") | |||
ver2, _ := gps.NewSemverConstraintIC("v2.0.0") | |||
master := gps.NewBranch("master") |
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 can be used inline. Other's are not inline because they do not return single value.
@JackyChiu This would be kinda off-topic. So, manifest.go has ValidateProjectRoots(), where it checks if the project names are actually project root. I think applicable constraints check in manifest can go within that function. And if you want to use |
@JackyChiu Also, can you clean up https://github.com/JackyChiu/dep-applicable-constraints/ ? I see a lot of tags in there and that could get confusing later 😅 |
Right that was off topic, and it turned out I didn't need to write a new function lol.
Forgot about all those, cleaned them up |
I've cloned the test repo https://github.com/darkowlzz/dep-applicable-constraints , you can change the repo names in the tests. And we should be ready with that. |
@darkowlzz 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.
LGTM
Thanks for working on it 👍 |
What does this do / why do we need it?
Makes the
collectConstraints
method collection only applicable constraints (constraints that are actually imported in the project). Does so by checking project constraints against direct deps.What should your reviewer look out for in this PR?
Implementation improvements
Do you need help or clarification on anything?
TestCollectConstraints
where the imports don't use all the constraints. Since it seems like only the maintainers should have their projects in the tests.Which issue(s) does this PR fix?
fixes #1409