Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Lint that flags usages of implicitly-dynamic values #262

Closed
wants to merge 2 commits into from

Conversation

ochafik
Copy link
Contributor

@ochafik ochafik commented Jun 16, 2016

Designed as a strong-mode-friendly replacement for always_specify_types and always_declare_return_types lints (complains about implicit dynamics at call sites instead of on declarations).

Accepts explicitly dynamic values, and lints against implicit ones used as invocation targets or downcast in argument / assignment positions.

cc/ @leafpetersen I believe you mentioned this kind of checks was on your radar for strong-mode, WDYT?

@ochafik ochafik force-pushed the no_implicit_dynamic branch from 70b5525 to 8ba05cc Compare June 16, 2016 02:18
@ochafik ochafik force-pushed the no_implicit_dynamic branch from 8ba05cc to 286ac47 Compare June 16, 2016 02:19
@alexeieleusis
Copy link
Contributor

I pulled this branch and the intellij dart plugin reports the same warnings than travis.

Also I don't know for sure what the policy is, but I think it would be a good idea to follow more closely https://www.dartlang.org/effective-dart/style/

I know there is a preference to sort methods alphabetically, though some of the code I have contributed does not follow that pattern, but IMO readability would improve if you place the public/inherited api methods before the private ones. I tend to use the java convention where the private methods are placed immediately after they are first used.

@alexeieleusis
Copy link
Contributor

I just realized that I might not be following the style guide, so that part might not apply.

@leafpetersen
Copy link
Member

For strong mode, we are planning to add a -no-implicit-dynamic option in the near future. cc/ @jmesserly @munificent who have both talked about picking this feature up.

@jmesserly
Copy link

dart-lang/sdk#25573 -- the Analyzer bug that I am looking at

ochafik added a commit to google/dart-scissors that referenced this pull request Jun 28, 2016
@pq
Copy link
Member

pq commented Feb 14, 2017

@ochafik : what's the status of this one? Needless to say, the world has changed a lot since you put this together... 😉 Is there anything worth pursuing?

final LintRule rule;
Visitor(this.rule);

Element _getBestElement(Expression node) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider to use getCanonicalElementFromIdentifier method from DartTypeUtilities (if applies)

bool _isImplicitDynamic(Expression node) {
if (node == null) return false;
while (node is ParenthesizedExpression) {
node = node.expression;
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider call _isImplicitDynamic(node.expression)

if (_isImplicitDynamic(target)) {
// Avoid double taxation (if `x` is dynamic, only lint `x.y.z` once).
Expression subTarget;
if (target is PropertyAccess) subTarget = target.realTarget;
Copy link
Contributor

@JPaulsen JPaulsen Apr 7, 2017

Choose a reason for hiding this comment

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

Perhaps it would be good idea to create a method that return an iterable with all targets, for example when you have something like:

a.b.foo().c.d.bar()[3].baz();

So if you can create a method, it could be also use in unnecessary_lambdas, where I had to do a similar check

@bwilkerson
Copy link
Member

@ochafik Have we abandoned this PR?

@pq
Copy link
Member

pq commented Jun 27, 2018

@ochafik: this is looking a bit stale (and would need rebasing regardless). Closing for now; feel to re-open if you want to take another pass.

Thanks!

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

Successfully merging this pull request may close these issues.

7 participants