Run DScanner on itself#479
Conversation
|
|
||
| private: | ||
|
|
||
| int level = 0; |
There was a problem hiding this comment.
FWIW I'm not really sold on the useless initializer check, but there weren't that many occurrences.
There was a problem hiding this comment.
Speaking of that i still have a PR opened that make the check very reliable. (#475)
There was a problem hiding this comment.
TBH, despite the recent discussion, I find D code without explicit initializers (when equal to .init) more clear to read, so LGTM.
There was a problem hiding this comment.
@bbasile I'll try to review your PR, but I don't have much knowledge of D-Scanner's internals.
src/analysis/style.d
Outdated
| enum string moduleNameRegex = `^[\p{Ll}_\d]+$`; | ||
| enum string VarFunNameRegex = `^([\p{Ll}_][_\w\d]*|[\p{Lu}\d_]+)$`; | ||
| enum string AggregateNameRegex = `^\p{Lu}[\w\d]*$`; | ||
| enum string ModuleNameRegex = `^[\p{Ll}_\d]+$`; |
There was a problem hiding this comment.
It's a bit ironic if a checker violates its own checks ;-)
There was a problem hiding this comment.
No, manifest constants like enum [type] identifier = <init-expr>;are variables, while enums like enum EnumerationName { member1, meber2 } are aggregates, IMO.
There was a problem hiding this comment.
ping, this is the only issue with the source left ;)
src/analysis/if_statements.d
Outdated
| return formatted == other.formatted | ||
| && line == other.line | ||
| && column == other.column | ||
| && depth == other.depth; |
There was a problem hiding this comment.
Doesn't this contradict the hash function, because it takes the formatted into account and toHash does not?
src/analysis/if_statements.d
Outdated
| } | ||
| size_t toHash() const nothrow | ||
| { | ||
| return line * 100_000 + column * 100 + depth; |
There was a problem hiding this comment.
I think better to rely on the built-in hashing here: https://github.com/dlang/druntime/blob/master/src/core/internal/hash.d
src/analysis/if_statements.d
Outdated
| return 0; | ||
| return -1; | ||
| } | ||
| bool opEquals(ref const ExpressionInfo other) const nothrow |
There was a problem hiding this comment.
Actually, are these functions added because of object_const_check? If that's the case I think this is a false positive, since the compiler already generates those functions for structs.
| auto identOrTemplate = type2.symbol.identifierOrTemplateChain | ||
| .identifiersOrTemplateInstances[0]; | ||
| const identOrTemplate = type2.symbol.identifierOrTemplateChain.identifiersOrTemplateInstances[0]; | ||
| if (identOrTemplate.templateInstance !is null) |
There was a problem hiding this comment.
Um, why? This lines is already 106 colons long with the two 4-width tabs.
PetarKirov
left a comment
There was a problem hiding this comment.
Overall look good to me, except where I have commented with an objection.
| if (guaranteeUse == 0) | ||
| { | ||
| const r = tree[index].equalRange(&vi); | ||
| auto r = tree[index].equalRange(&vi); |
There was a problem hiding this comment.
This lead to the compile error on Travis:
src/analysis/unmodified.d(202): Error: mutable method std.container.rbtree.RBRange!(RBNode!(VariableInfo*)*).RBRange.front is not callable using a const object
There was a problem hiding this comment.
I'll submit a Phobos PR for that (I already have the fix locally, but I want to add some tests), but that's the right way to go, since we support multiple versions of Phobos anyway.
It's due to the |
Yeah, I was looking for
Yes, we can always discus them later. |
Yep, no problem, but individual commits are extremely helpful when reviewing ;) |
makefile
Outdated
| rm -f bin/dscanner-unittest | ||
|
|
||
| lint: dmdbuild | ||
| ./dsc --config .dscanner.ini --styleCheck src |
There was a problem hiding this comment.
./dsc --config .dscanner.ini --styleCheck src ->
./bin/dscanner --config .dscanner.ini --styleCheck src
(There's no dsc as far as I can see.)
| else | ||
| git submodule update --init --recursive | ||
| make test | ||
| make lint |
There was a problem hiding this comment.
I heavily prefer if we ran lint on both the ldc, dmd and the dub build.
Hmm I don't mind, but on my machine it takes ~40s (~1.5min on CircleCI) to do the release build and the source code doesn't change ...
|
The idea is more about testing the compilers than anything else, but I'm fine with leaving it as it is. Issues like that one easily hide in the shadows until someone hits them somewhere deep in their non-trivial codebase. |
|
I decided to move compiler testing discussion to different PR/issue in the interest of time, as the core of the PR was complete. |
No description provided.