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

Make shelly understand class-dependencies and how to import them #24

Open
krdln opened this issue Oct 5, 2018 · 4 comments
Open

Make shelly understand class-dependencies and how to import them #24

krdln opened this issue Oct 5, 2018 · 4 comments
Labels
enhancement New feature or request lint-suggestion A feature request for new lint

Comments

@krdln
Copy link
Owner

krdln commented Oct 5, 2018

Consider:

A.ps1

class A {}

B.ps1

class B {
    [A] $Field
}

If B.ps1 would just dot-import A.ps1, it wouldn't work (because powershell parses classes before sourcing files). However, if there was:

C.ps1

. $PSScriptRoot/A.ps1
. $PSScriptRoot/B.ps1

both A and B would be happily imported. I've noticed such a pattern started occurring in the wild – A.ps1 and B.ps1 are never imported directly, but only through a C.ps1 "import wrapper". When using class A through such a wrapper, shelly currently does weird things:

  • Warns about unused imports of A.ps1 and B.ps1 in C.ps1.
  • Warns about indirect usage of B.ps1 in files that import only C.ps1 wrapper.
  • (Fortunately doesn't scream about unknown class [A] in B.ps1, but it should)

I have no idea what to do about it. It would be nice to detect such a pattern, disable stupid warnings, and perhaps emit a lint if dependent class is used without a wrapper.

For now, I think I'm going to just disable indirect-imports and unused-imports on classes.

cc @m-kostrzewa @sodar

@krdln krdln added enhancement New feature or request lint-suggestion A feature request for new lint labels Oct 5, 2018
@m-kostrzewa
Copy link
Collaborator

yup, @sodar gave up when I showed him this :)

@sodar
Copy link

sodar commented Oct 9, 2018

That puts it mildly.

@krdln
Copy link
Owner Author

krdln commented Oct 10, 2018

@sodar @m-kostrzewa Can you verify if the current version is free of false warnings in winci?

@m-kostrzewa
Copy link
Collaborator

@krdln sure, tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lint-suggestion A feature request for new lint
Projects
None yet
Development

No branches or pull requests

3 participants