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

Basic traverse and linter rules #78

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Basic traverse and linter rules #78

wants to merge 3 commits into from

Conversation

tkers
Copy link
Member

@tkers tkers commented Apr 8, 2019

This needs some improvement around the Module | Syntax parts still, as a lot of functions could be merged.

@codecov
Copy link

codecov bot commented Apr 8, 2019

Codecov Report

Merging #78 into master will decrease coverage by 3.21%.
The diff coverage is 11.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
- Coverage   90.55%   87.34%   -3.22%     
==========================================
  Files          31       32       +1     
  Lines        1440     1501      +61     
  Branches      227      241      +14     
==========================================
+ Hits         1304     1311       +7     
- Misses        118      172      +54     
  Partials       18       18
Impacted Files Coverage Δ
packages/delisp-core/src/index.ts 100% <100%> (ø) ⬆️
packages/delisp-core/src/linter.ts 12% <12%> (ø)
packages/delisp-core/src/syntax-utils.ts 52.74% <8.57%> (-27.61%) ⬇️

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 b157b35...4c384de. Read the comment docs.

@tkers tkers force-pushed the basic-linter branch 2 times, most recently from e526a0b to b5b67ec Compare April 8, 2019 22:12
@tkers tkers force-pushed the basic-linter branch 2 times, most recently from 4c384de to c50e213 Compare April 8, 2019 22:13
Copy link
Member

@davazp davazp left a comment

Choose a reason for hiding this comment

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

I find confusing a little bit what we consider a binding. Firstly it seemed it was only local variables + function arguments. But then module did extract definitions.

A couple of alternative ideas to make it more clear:

  • Remove syntaxBindings (do it inside module directly).
  • Define 2 kind of bindings, lexical-global.

return expressionBindings(s);
} else {
switch (s.node.tag) {
case "definition":
Copy link
Member

Choose a reason for hiding this comment

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

Should definition also include a binding?

Copy link
Member Author

@tkers tkers Apr 9, 2019

Choose a reason for hiding this comment

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

These are global bindings, so handled by the moduleBindings. This function returns the bindings that only exist within the node.

switch (s.node.tag) {
case "definition":
case "export":
case "type-alias":
Copy link
Member

Choose a reason for hiding this comment

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

I get the rule is unused-variables, but maybe it would make sense to extend it to unused types as well?

}

function moduleBindings<I>(m: Module<I>): Identifier[] {
return moduleChildren(m)
Copy link
Member

Choose a reason for hiding this comment

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

I would have expected this in syntaxBindings actually.

@davazp
Copy link
Member

davazp commented Apr 9, 2019

It would be nice to find a more functional-friendly way of writing rules. The visitor patterns rely too much on the execution order and keeping state. It's quite imperative.

It would be interesting if we can compare with other implementations at some point.

But this looks good, with a bit of clean up and tests we can merge it. It should be easy to maintain.

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.

None yet

2 participants