Skip to content
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

Remove use of deprecated utils functions & Enable deprecation linter #2169

Merged
merged 19 commits into from
Jun 17, 2024

Conversation

awharn
Copy link
Member

@awharn awharn commented Jun 6, 2024

What It Does

Stops using deprecated utility functions
Changes logic to use require.main over process.mainModule, which is deprecated
Enables linters for detecting extra parenthesis and deprecated function use

How to Test

Review Checklist
I certify that I have:

Additional Comments

Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
… abort

Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 91.06628% with 31 lines in your changes missing coverage. Please review.

Project coverage is 91.18%. Comparing base (bbffec2) to head (bf8d8ad).
Report is 2 commits behind head on next.

Files Patch % Lines
...ackages/imperative/src/cmd/src/CommandProcessor.ts 80.00% 3 Missing ⚠️
...s/imperative/src/cmd/src/syntax/SyntaxValidator.ts 90.62% 3 Missing ⚠️
...perative/src/cmd/src/yargs/AbstractCommandYargs.ts 57.14% 3 Missing ⚠️
...kages/imperative/src/cmd/src/yargs/CommandYargs.ts 70.00% 3 Missing ⚠️
...s/imperative/src/imperative/src/OverridesLoader.ts 50.00% 3 Missing ⚠️
...workflows/delete/Delete.archived.common.handler.ts 50.00% 2 Missing ⚠️
...src/cmd/src/help/abstract/AbstractHelpGenerator.ts 81.81% 2 Missing ⚠️
...es/imperative/src/config/src/ProfileCredentials.ts 66.66% 2 Missing ⚠️
...ackages/imperative/src/operations/src/Operation.ts 0.00% 2 Missing ⚠️
...ckages/imperative/src/operations/src/Operations.ts 50.00% 2 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2169      +/-   ##
==========================================
- Coverage   91.18%   91.18%   -0.01%     
==========================================
  Files         628      628              
  Lines       17874    17850      -24     
  Branches     3796     3693     -103     
==========================================
- Hits        16299    16276      -23     
+ Misses       1574     1573       -1     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

awharn and others added 5 commits June 6, 2024 15:38
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
packages/imperative/src/utilities/src/TextUtils.ts Dismissed Show dismissed Hide dismissed
packages/imperative/src/utilities/src/TextUtils.ts Dismissed Show dismissed Hide dismissed
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

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

Looks pretty good, thanks @awharn! Left a few comments

packages/.madgerc Outdated Show resolved Hide resolved
packages/cli/scripts/validatePlugins.js Outdated Show resolved Hide resolved
@@ -70,7 +70,7 @@ export default class ApimlAutoInitHandler extends BaseAutoInitHandler {
*/
protected async doAutoInit(session: AbstractSession, params: IHandlerParameters): Promise<IConfig> {
// Login with token authentication first, so we can support certificates
if ((session.ISession.user && session.ISession.password) || (session.ISession.cert && session.ISession.certKey)) {
if (session.ISession.user && session.ISession.password || session.ISession.cert && session.ISession.certKey) {
Copy link
Member

Choose a reason for hiding this comment

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

Generally I like the no-extra-parens rule, but in a few cases like this one it may make the code less readable. I'm probably just dumb but it's not obvious to me what the order of precedence is across these 4 conditions. Not a request to change anything, just an observation 😋

packages/imperative/src/logger/src/Logger.ts Outdated Show resolved Hide resolved
Comment on lines 124 to 126
const initPath = ImperativeConfig.instance.callerLocation ?? require.main.filename;
if (initPath != null) {
requireOpts.paths = [initPath, ...require.resolve.paths("@zowe/secrets-for-zowe-sdk")];
Copy link
Member

Choose a reason for hiding this comment

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

We may want to keep the code structured the same as before:

Suggested change
const initPath = ImperativeConfig.instance.callerLocation ?? require.main.filename;
if (initPath != null) {
requireOpts.paths = [initPath, ...require.resolve.paths("@zowe/secrets-for-zowe-sdk")];
if (require.main?.filename != null) {
requireOpts.paths = [require.main.filename, ...require.resolve.paths("@zowe/secrets-for-zowe-sdk")];

I don't think we want to add a reference to ImperativeConfig.instance here because it is called by extenders like Zowe Explorer outside of a CLI context where the Imperative config is undefined.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was under the impression that was the reason why it falls back to require.main.filename, since if there is no callerLocation, then it just behaves as it did before.

Copy link
Member

Choose a reason for hiding this comment

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

Follow up to our earlier discussion - ImperativeConfig.instance.callerLocation returns null so it would be ok to access in Zowe Explorer. However this may only be because we call ProfileInfo.initImpUtils which initializes a fake Imperative config object. Thanks for removing the reference, I think it is the safer option for extenders using our SDKs - will leave this comment unresolved for now to get a second opinion 😋

Comment on lines 44 to 45
const maxWidth = !((yargs.terminalWidth() && yargs.terminalWidth() > 0) == null) ?
yargs.terminalWidth() - widthSafeGuard : preferredWidth;
Copy link
Member

Choose a reason for hiding this comment

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

This faithfully reflects the old logic, but I think the old logic may have been wrong - would the following make more sense?

Suggested change
const maxWidth = !((yargs.terminalWidth() && yargs.terminalWidth() > 0) == null) ?
yargs.terminalWidth() - widthSafeGuard : preferredWidth;
const maxWidth = (!(yargs.terminalWidth() == null) && yargs.terminalWidth() > 0) ?
yargs.terminalWidth() - widthSafeGuard : preferredWidth;

packages/zosfiles/src/methods/create/Create.ts Outdated Show resolved Hide resolved
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
@t1m0thyj t1m0thyj self-requested a review June 11, 2024 22:54
…nter

Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @awharn!

Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for all your work on this Andrew! I left a couple comments but I don't have any requests for changes.

Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
…nter

Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Copy link

sonarcloud bot commented Jun 17, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
79.2% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@awharn awharn merged commit 38ac81f into next Jun 17, 2024
45 of 46 checks passed
@awharn awharn deleted the enable-deprecation-linter branch June 17, 2024 20:15
Copy link

Release succeeded for the next branch. 🎉

The following packages have been published:

  • npm: @zowe/secrets-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/imperative@8.0.0-next.202406172053
  • npm: @zowe/cli-test-utils@8.0.0-next.202406172053
  • npm: @zowe/core-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-uss-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/provisioning-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-console-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-files-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-logs-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zosmf-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-workflows-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-jobs-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/zos-tso-for-zowe-sdk@8.0.0-next.202406172053
  • npm: @zowe/cli@8.0.0-next.202406172053

Powered by Octorelease 🚀

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

Successfully merging this pull request may close these issues.

3 participants