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

Use Fewer Deprecated Functions in Master #2217

Merged
merged 11 commits into from
Aug 8, 2024
Merged

Conversation

awharn
Copy link
Member

@awharn awharn commented Aug 6, 2024

What It Does

Resolves #2191
Reduces the use of deprecated functions in preparation to support Node 22

How to Test

Install, build, run commands to verify new build does not trigger deprecation warnings on Node 22

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>
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>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 96.82540% with 6 lines in your changes missing coverage. Please review.

Project coverage is 91.15%. Comparing base (5883be1) to head (bd6d84c).

Files Patch % Lines
...src/cmd/src/help/abstract/AbstractHelpGenerator.ts 80.00% 2 Missing ⚠️
...s/imperative/src/cmd/src/syntax/SyntaxValidator.ts 91.30% 2 Missing ⚠️
...li/src/zosconsole/issue/command/Command.handler.ts 66.66% 1 Missing ⚠️
...ckages/imperative/src/operations/src/Operations.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2217      +/-   ##
==========================================
- Coverage   91.16%   91.15%   -0.01%     
==========================================
  Files         638      638              
  Lines       19134    19103      -31     
  Branches     4041     4041              
==========================================
- Hits        17444    17414      -30     
+ Misses       1689     1688       -1     
  Partials        1        1              

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

@awharn
Copy link
Member Author

awharn commented Aug 7, 2024

Please wait to merge - system tests are in progress.

Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
@@ -2,6 +2,10 @@

All notable changes to the Zowe CLI test utils package will be documented in this file.

## Recent Changes

- BugFix: Refactored code to reduce the use of deprecated functions to prepare for Node 22 support. [#2191](https://github.com/zowe/zowe-cli/issues/2191)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we explain why we need Node 22 support?

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 don't quite know how to explain it in the changelog. The CLI supports running on all Node LTS versions that are actively supported by the NodeJS project maintainers, and Node 22 will reach that point in October. That commitment is documented in the Zowe CLI system requirements. This PR sets the ground work to honor that commitment.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about: " ... upcoming NodeJS 22 support"

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. Changelogs updated. Thanks!

@awharn
Copy link
Member Author

awharn commented Aug 7, 2024

System Tests are complete and pass.

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

@anaxceron anaxceron left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @awharn!

Copy link
Member

@zFernand0 zFernand0 left a comment

Choose a reason for hiding this comment

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

LGTM! 😋

All of my comments are mostly minor things that can be done at a later time, or be forgotten since they should not impact performance or behavior 😋

Copy link
Member

Choose a reason for hiding this comment

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

Is there a way we could avoid having to maintain a separate tsconfig.json file in every package?

I'm thinking of techniques similar to how jest config can be combined.

Not really requesting changes, though! 😋

Copy link
Member Author

Choose a reason for hiding this comment

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

We made the same change in Next, but no, I don't think there is anything we can do. ESLint expects a TSConfig everywhere it scans, and you need different TSConfigs between tests and source. We could try to have them all extend a common TSConfig, but that would need to be a separate effort in V3. I don't expect we will change any of these TSConfigs through the rest of V2.

packages/imperative/tsconfig-tests.json Outdated Show resolved Hide resolved
@@ -274,7 +274,7 @@ export class TextUtils {
* @returns {string} - a formatted string with the variables inserted
*/
public static formatMessage(message: string, ...values: any[]): string {
if (!isNullOrUndefined(values)) {
if (!(values == null)) {
Copy link
Member

Choose a reason for hiding this comment

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

There are multiple occasions (in this file and maybe others) where we do !(a == null) instead of a != null Curious if we could replace them with the shorthand version of != null 😋

Copy link
Member Author

@awharn awharn Aug 8, 2024

Choose a reason for hiding this comment

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

That is what the hundred plus issues flagged are. I just did this as shorthand since when I did that on V3, I made several mistakes when trying to do exactly that change that ended up breaking people and causing issues. This will all go away in V3, I just wanted to minimize the amount of time spent and mistakes made in V2.

@@ -200,12 +200,12 @@ export abstract class AbstractProfileManager<T extends IProfileTypeConfiguration
if (parms.loadCounter != null) {
this.mLoadCounter = parms.loadCounter;
}
this.mLogger = isNullOrUndefined(parms.logger) ? this.mLogger : parms.logger;
this.mLogger = parms.logger == null ? this.mLogger : parms.logger;
Copy link
Member

Choose a reason for hiding this comment

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

It is possible that this comment may apply to other files...

Curious if we should take advantage of other operators like ?? 😋

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 just doing a find and replace. I was not evaluating any of the other logic. I would think if we want to change something like this, it might make more sense as another issue in order to reduce scope creep.

this.mProfileType = parms.type;
this.mProfileRootDirectory = parms.profileRootDirectory;
this.mProfileTypeConfigurations = parms.typeConfigurations;
this.mProductDisplayName = parms.productDisplayName;
if (isNullOrUndefined(this.profileTypeConfigurations) || this.profileTypeConfigurations.length === 0) {
if (this.profileTypeConfigurations == null || this.profileTypeConfigurations.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Similar to the previous comment...

what about using ?. 😋

There are edge cases where ?. may not be desired since it can technically change the behavior. For example, if (a != null && !a.booleanValue) is not the same as if (!a?.booleanValue) since the condition will evaluate to true if A 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.

Same as previous comment.

@@ -21,6 +21,7 @@ import * as yargs from "yargs";
import { ImperativeError } from "../../error/src/ImperativeError";

describe("Imperative", () => {
// eslint-disable-next-line deprecation/deprecation
const mainModule = process.mainModule;
Copy link
Member

Choose a reason for hiding this comment

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

Curious if there is a way to configure the deprecation/deprecation eslint plug-in to ignore all uses of process.mainModule 😋

Copy link
Member Author

Choose a reason for hiding this comment

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

There is not. I checked.

Comment on lines 41 to 51
/**
* Loaded z/OSMF profile if needed
* @deprecated
*/
protected mZosmfProfile: IProfile;

/**
* Loaded z/OSMF profile with meta information
* @deprecated
*/
protected mZosmfLoadedProfile: IProfileLoaded;
Copy link
Member

Choose a reason for hiding this comment

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

Are this newly deprecated properties?

I believe they still exist in the next branch 😋

Should we create an issue to remove them/replace them over there?

Copy link
Member Author

@awharn awharn Aug 8, 2024

Choose a reason for hiding this comment

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

I only deprecated them because the code around them didn't actually do anything, and the process of setting them used deprecated functions. I can undo this if we prefer.

Copy link
Member Author

Choose a reason for hiding this comment

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

After in person discussion, we are planning to remove these in V3 since nothing sets the protected variables anymore.

packages/zosuss/src/SshBaseHandler.ts Show resolved Hide resolved
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!

packages/.madgerc Outdated Show resolved Hide resolved
packages/imperative/package.json Outdated Show resolved Hide resolved
packages/imperative/src/utilities/src/TextUtils.ts Outdated Show resolved Hide resolved
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Signed-off-by: Andrew W. Harn <andrew.harn@broadcom.com>
Copy link

sonarcloud bot commented Aug 8, 2024

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

@gejohnston gejohnston left a comment

Choose a reason for hiding this comment

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

Thanks for the painstaking effort.

@awharn awharn merged commit de6aacc into master Aug 8, 2024
21 checks passed
@awharn awharn deleted the fix-deprecation-master branch August 8, 2024 15:26
@awharn awharn added the release-current Indicates that there is no new functionality being delivered label Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-current Indicates that there is no new functionality being delivered
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

Remove deprecated methods in V2
5 participants