Skip to content

Added FSWatching base class and made related changes - #14605

Merged
Kartik Raj (karrtikr) merged 10 commits into
microsoft:mainfrom
karrtikr:baseclass
Nov 6, 2020
Merged

Kartik Raj (karrtikr) merged 10 commits into
microsoft:mainfrom
karrtikr:baseclass

Conversation

@karrtikr

Copy link
Copy Markdown

Created a work item to move all low level locators separately.

@codecov-io

Codecov (codecov-io) commented Nov 4, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #14605 into main will decrease coverage by 64.89%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #14605       +/-   ##
===========================================
- Coverage   64.89%    0.00%   -64.90%     
===========================================
  Files         541        4      -537     
  Lines       25156       11    -25145     
  Branches     3545        0     -3545     
===========================================
- Hits        16324        0    -16324     
+ Misses       8170       11     -8159     
+ Partials      662        0      -662     
Impacted Files Coverage Δ
src/client/debugger/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/common/process/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/common/platform/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/interpreter/autoSelection/constants.ts 0.00% <0.00%> (-100.00%) ⬇️
src/client/interpreter/display/progressDisplay.ts
src/client/terminals/activation.ts
src/client/formatters/helper.ts
src/client/testing/codeLenses/main.ts
src/client/common/experiments/groups.ts
src/client/common/process/proc.ts
... and 526 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f752706...21b740a. Read the comment docs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for working on this, Kartik Raj (@karrtikr). I think you're on the right track. My main recommendation is that you give FSWatchingLocator a meaningful purpose. Otherwise I don't think there is anything too major here, though I've noted a few places where I have concerns about correctness.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've left a few relatively minor comments for which I'd appreciate a resolution before this gets merged.

Otherwise, LGTM.

/**
* Location(s) to watch for python binaries.
*/
private readonly getRoots: () => Promise<string[]> | string,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
private readonly getRoots: () => Promise<string[]> | string,
private readonly getRoots: () => Promise<string[]> | string[],

@karrtikr Kartik Raj (karrtikr) Nov 5, 2020 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Actually it's getRoot(s) as explained in the doc. Not every locator has an array of locations they want to search (getWindowsAppsRoot), some just have a single location, so this is just convenience.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have added the string[] type but not removed string.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If they have a single location then they return a single element array. Returning string means that the caller always has to check typeof result === 'string'. So it makes things simpler if we only return Promise<string[]> | string[].

(Also note that if you support return string then the return type should be Promise<string[] | string> | string[] | string. However, as I said, I don't think the distinction between string[] and string adds any value while it increases complexity.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Returning string means that the caller always has to check typeof result === 'string'

I don't think so.. not sure why you say that. The caller for the "string" case here just passes in

constructor() {
    super(
        getWindowsStoreAppsRoot,
        async () => this.kind,
        { executableBaseGlob: pythonExeGlob },
    );
}

While in string[] case

constructor() {
    super(
        () => [getWindowsStoreAppsRoot()],
        async () => this.kind,
        { executableBaseGlob: pythonExeGlob },
    );
}

So adding the string type decreases complexity for the caller. Note this is just convenience.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah, I see the problem. I was expecting it to return one of the following (and I believe it does):

  • () => Promise<string[]>
  • () => string[]
  • () => string

While you appear to be thinking it is:

  • () => Promise<string[]>
  • string[]
  • string

I'm pretty sure the correct form to also meet your expectations is:

string[] | string | () => Promise<string[]> | string[]

Though parentheses might be needed:

string[] | string | (() => Promise<string[]> | string[])

FWIW, I agree that the string[] | string types are convenient and should be okay.

@sonarqubecloud

ghost commented Nov 5, 2020

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@karrtikr
Kartik Raj (karrtikr) merged commit 16d4701 into microsoft:main Nov 6, 2020
@karrtikr
Kartik Raj (karrtikr) deleted the baseclass branch November 6, 2020 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

4 participants