这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@RahulGautamSingh
Copy link
Collaborator

Changes

  • Use isNullOrUndefined check instead of ?(optional chaining) which can let some edge cases in

Context

Please select one of the below:

  • This closes an existing Issue, Closes: Linter refactoring broke logic #39228
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@astellingwerf
Copy link
Collaborator

I can't help but feel icky that we can change this code back and forth without breaking any test. That also makes it hard for me to grasp why out of the 8 cases in #38897 seemingly matching the pattern, only 6 need a fix.

@RahulGautamSingh
Copy link
Collaborator Author

I can't help but feel icky that we can change this code back and forth without breaking any test. That also makes it hard for me to grasp why out of the 8 cases in #38897 seemingly matching the pattern, only 6 need a fix.

Agreed. I will add tests for these cases as well.

Regarding 6/8 cases needing the change. The other 2 cases are && expressions and not || and I verified that they pass the checks.

@jamietanna
Copy link
Contributor

Can we add misisng tests? Then we can check that things are broken before this PR's changes, then when applying this change, they should be fixed?

config,
}: UpdateArtifact): Promise<UpdateArtifactsResult[] | null> {
if (updatedDeps?.length !== 1) {
if (isNullOrUndefined(updatedDeps) || updatedDeps.length !== 1) {
Copy link
Collaborator Author

@RahulGautamSingh RahulGautamSingh Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (isNullOrUndefined(updatedDeps) || updatedDeps.length !== 1) {
if (updatedDeps?.length !== 1) {

This is fine as the logic behaves correctly when updateDeps is null | undefined. But, the debug message inside the if-check breaks, so need to fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, use the optional chaining here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be reverted. If the sha256=null|undefined the logic is working fine.

There's also a test to confirm this already present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing expression is not broken as the value will be compared to a constant value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this change isn't required? please leave as is then

@RahulGautamSingh
Copy link
Collaborator Author

@astellingwerf Could you please review again. I have added tests where possible and have added a comment on the other file where the existing logic is not breaking or a test cannot be added.

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

@viceice viceice changed the title fix: broken logic from #38897 fix(copier): broken logic Nov 12, 2025
@viceice viceice changed the title fix(copier): broken logic fix(copier): broken log message Nov 12, 2025
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

Copy link
Collaborator

@astellingwerf astellingwerf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants