Skip to content

Comments

Run DScanner on itself#479

Merged
PetarKirov merged 7 commits intodlang-community:masterfrom
wilzbach:enable-dscanner
Jun 25, 2017
Merged

Run DScanner on itself#479
PetarKirov merged 7 commits intodlang-community:masterfrom
wilzbach:enable-dscanner

Conversation

@wilzbach
Copy link
Member

No description provided.


private:

int level = 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW I'm not really sold on the useless initializer check, but there weren't that many occurrences.

Copy link

Choose a reason for hiding this comment

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

Speaking of that i still have a PR opened that make the check very reliable. (#475)

Copy link
Member

@PetarKirov PetarKirov Jun 25, 2017

Choose a reason for hiding this comment

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

TBH, despite the recent discussion, I find D code without explicit initializers (when equal to .init) more clear to read, so LGTM.

Copy link
Member

Choose a reason for hiding this comment

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

@bbasile I'll try to review your PR, but I don't have much knowledge of D-Scanner's internals.

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]+$`;
Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit ironic if a checker violates its own checks ;-)

Copy link
Member

Choose a reason for hiding this comment

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

No, manifest constants like enum [type] identifier = <init-expr>;are variables, while enums like enum EnumerationName { member1, meber2 } are aggregates, IMO.

Copy link
Member

@PetarKirov PetarKirov Jun 25, 2017

Choose a reason for hiding this comment

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

ping, this is the only issue with the source left ;)

return formatted == other.formatted
&& line == other.line
&& column == other.column
&& depth == other.depth;
Copy link
Member

@PetarKirov PetarKirov Jun 25, 2017

Choose a reason for hiding this comment

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

Doesn't this contradict the hash function, because it takes the formatted into account and toHash does not?

}
size_t toHash() const nothrow
{
return line * 100_000 + column * 100 + depth;
Copy link
Member

Choose a reason for hiding this comment

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

return 0;
return -1;
}
bool opEquals(ref const ExpressionInfo other) const nothrow
Copy link
Member

@PetarKirov PetarKirov Jun 25, 2017

Choose a reason for hiding this comment

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

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)
Copy link
Member

@PetarKirov PetarKirov Jun 25, 2017

Choose a reason for hiding this comment

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

Um, why? This lines is already 106 colons long with the two 4-width tabs.

Copy link
Member

@PetarKirov PetarKirov left a comment

Choose a reason for hiding this comment

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

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);
Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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.

@wilzbach
Copy link
Member Author

@ZombineDev

Actually, are these functions added because of object_const_check?

It's due to the opequals_tohash_check, but I think it's better to go with a minimal load of checks in the beginning and discuss on a solution for enabling these checks on a case by case basis ;-)
That's why I removed the controversial bits and set the checks to disabled.
Of course, we should squash all commits into one.

@PetarKirov
Copy link
Member

It's due to the opequals_tohash_check

Yeah, I was looking for opequals_tohash_check, but somehow I only found object_const_check when searching for toHash. Strange.

That's why I removed the controversial bits and set the checks to disabled.

Yes, we can always discus them later.

@PetarKirov
Copy link
Member

Of course, we should squash all commits into one.

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
Copy link
Member

@PetarKirov PetarKirov Jun 25, 2017

Choose a reason for hiding this comment

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

./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
Copy link
Member

Choose a reason for hiding this comment

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

I heavily prefer if we ran lint on both the ldc, dmd and the dub build.

@wilzbach
Copy link
Member Author

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 ...
Btw if we already talk about the Makefile I would be strongly in favor of

  • allowing a "slim" debug build (=debug without logging, at Phobos we already patch DScanner for this as building the debug version is a lot faster)
  • use non-changing target that don't run when no source file has changed (with the current makefile make lint will always build DScanner)

@PetarKirov
Copy link
Member

PetarKirov commented Jun 25, 2017

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.
For example things such as this: ldc-developers/druntime@16d80d5 o_O (from ldc-developers/ldc#2076).

Issues like that one easily hide in the shadows until someone hits them somewhere deep in their non-trivial codebase.

@PetarKirov PetarKirov merged commit 61d5215 into dlang-community:master Jun 25, 2017
@PetarKirov
Copy link
Member

PetarKirov commented Jun 25, 2017

I decided to move compiler testing discussion to different PR/issue in the interest of time, as the core of the PR was complete.

@wilzbach wilzbach deleted the enable-dscanner branch July 1, 2017 20:12
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.

2 participants