-
Notifications
You must be signed in to change notification settings - Fork 692
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
Fix sample analysis build jobs #2575
Conversation
I'm not sure if any of these are used in the docs... but should we get the same results?
Don't let the Travis build passing fool you... analysis still fails. (I should've updated .travis.yml.) Here's how it fails now: https://travis-ci.org/github/dart-lang/site-www/jobs/717457700. |
This seemed to be broken becuase of a deleted/renamed file (`animal_bad.dart` & `common_problems_analysis.dart`).
The reason the build is failing is, apparently, that errors can no longer be ignored. There's a discussion at dart-lang/sdk#42977. |
These are existing warnings that we'd ignored that became unsilenceable errors in 2.9
…hat incorrectly ignores expected analysis-results files on travis
…ed these from has been removed due to it being invalid code in 2.9
…for examples/strong
It ain't easy being green. 🐸 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions, and some places where I'd like to consult with people who've been working on them (Bob for Effective Dart, John for the site infra), but I'm so happy to have this running again!
@@ -1,6 +1,6 @@ | |||
void miscDeclAnalyzedButNotTested() { | |||
var fruits = List<String>(); | |||
// ignore_for_file: stable, dev, argument_type_not_assignable | |||
// ignore_for_file: stable, dev, argument_type_not_assignable, unused_local_variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add beta to this list? Or remove the release names?
(Is "beta" even supported? I don't see examples/strong/analyzer-results-beta.txt in this PR.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure? I can't quite figure out how that works. If there isn't a -beta.txt
file it uses analyzer-results.txt
, and I think most of the beta files that existed were fine.
@@ -1,18 +1,11 @@ | |||
Analyzing analysis_options.yaml, lib, test... | |||
error • 'HoneyBadger.parent' ('Root Function()') isn't a valid override of 'Animal.parent' ('Animal Function()'). • lib/animal_bad.dart:15:12 • invalid_override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file different from analyzer-results-stable.txt? If not, then maybe we should remove one of these files and delete "-stable" from the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's identical.
@@ -1281,8 +1281,10 @@ num highScore(List<num> scores) { | |||
} | |||
{% endprettify %} | |||
|
|||
<!-- Q: As of 2.9, this code no longer works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@munificent opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't it work? Because we're getting rid of implicit downcasts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't it work? Because we're getting rid of implicit downcasts?
Yes, I think so. Here's the message, which complains about highest
(an int
) being assigned score
(a num
).
error * A value of type 'num' can't be assigned to a variable of type 'int'. * lib/effective_dart/design_bad.dart:79:38 * invalid_assignment
num highScore(List<num> scores) {
var highest = 0;
for (var score in scores) {
// ignore: invalid_assignment
if (score > highest) highest = score;
}
return highest;
}
@@ -1072,8 +1072,10 @@ If a field doesn't depend on any constructor parameters, it can and should be | |||
initialized at its declaration. It takes less code and makes sure you won't | |||
forget to initialize it if the class has multiple constructors. | |||
|
|||
<!-- Q: As of 2.9, this code no longer works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@munificent opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this elsewhere, but to close the loop here, I think we should make contents
non-final (assuming I'm guessing correctly at what no longer works).
{% prettify dart tag=pre+code %} | ||
bool b = [0][0]; | ||
{% endprettify %} | ||
|
||
With type-safe Dart, the analyzer produces the following error: | ||
|
||
{:.console-output} | ||
<?code-excerpt "strong/analyzer-results-stable.txt" retain="/'int' can't be .* 'bool'.*common_problems/"?> | ||
<!-- code-excerpt "strong/analyzer-results-stable.txt" retain="/'int' can't be .* 'bool'.*common_problems/" --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we uncomment the code-excerpt tag? Otherwise, the analyzer message could change and we wouldn't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that since we removed the files that generate those errors, we can't get that error excerpt from those files (same applies to the other comments about this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well drat. I think it's fine for now, but since analysis messages do change, I could file a bug about fixing that.
Or... since analyzer messages are now listed & explained in https://dart.dev/tools/diagnostic-messages, for some messages at least we could have static (not included) text that links to the message description there (in another PR). An advantage of this approach is that if/when the message changes, @bwilkerson has started adding forwarding links to the old links. (See the discussion at #2569.)
@@ -55,9 +54,9 @@ see [Runtime errors](#common-errors-and-warnings). | |||
|
|||
### Undefined member | |||
|
|||
<?code-excerpt "strong/analyzer-results-stable.txt" retain="/isn't defined for the type.*common_problems/" replace="/getter/<member\x3E/g; /'\w+'/'...'/g"?> | |||
<!-- code-excerpt "strong/analyzer-results-stable.txt" retain="/isn't defined for the type.*common_problems/" replace="/getter/<member\x3E/g; /'\w+'/'...'/g" --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we uncomment the code-excerpt? (I have the same question for every other commented-out code-excerpt in this file where we show the error text. :)
@@ -73,24 +73,6 @@ function analyze_and_test() { | |||
EXPECTED_FILE=$PROJECT_ROOT/analyzer-results.txt | |||
fi | |||
travis_fold start analyzeAndTest.analyze | |||
if [[ -e $EXPECTED_FILE && -z $QUICK ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnpryan fyi
let's file a bug for adding links for all analysis messages.
…On Thu, Aug 13, 2020 at 5:49 PM Kathy Walrath ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/_guides/language/sound-problems.md
<#2575 (comment)>:
> {% prettify dart tag=pre+code %}
bool b = [0][0];
{% endprettify %}
With type-safe Dart, the analyzer produces the following error:
{:.console-output}
-<?code-excerpt "strong/analyzer-results-stable.txt" retain="/'int' can't be .* 'bool'.*common_problems/"?>
+<!-- code-excerpt "strong/analyzer-results-stable.txt" retain="/'int' can't be .* 'bool'.*common_problems/" -->
Well drat. I think it's fine for now, but since analysis messages do
change, I could file a bug about fixing that.
Or... since analyzer messages are now listed & explained in
https://dart.dev/tools/diagnostic-messages, for some messages at least we
could have static (not included) text that links to the message description
there (in another PR). An advantage of this approach is that if/when the
message changes, @bwilkerson <https://github.com/bwilkerson> has started
adding forwarding links to the old links. (See the discussion at #2569
<#2569>.)
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#2575 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I42TVO35ZXWGRF7YZDDSARNU7ANCNFSM4P5T7EEQ>
.
|
@johnpryan could you approve this? Turns out I shouldn't because it started out as my PR... |
Sure, taking a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think we need to adjust our strategy for analyzing "bad" snippets, if we choose to try to analyze them again. It might be reasonable to keep them unanalyzed since we're still analyzing the "good" ones. The downside is that we will be relying on contributors checking the bad snippet if they make a change to the good one.
@@ -7,9 +7,9 @@ int timesTwo(int x) { | |||
int timesFour(int x) => timesTwo(timesTwo(x)); | |||
|
|||
// Functions are objects. | |||
int runTwice(int x, Function f) { | |||
int runTwice(int x, int Function(int) f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just FYI I just merged a change that moves this snippet into dartpad_picker_main. I created an issue to track: #2581
I had to disregard sample analysis (see f5af1bd) to fix the build when 2.9 stable was released.
But the site should always pass static analysis in the stable build, and preferably the beta build as well (#2525).
I'm uploading my work in progress, so @theacodes can (I hope) take it over and actually fix the build.