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

false positive in style checker, checking casts #781

Closed
ghost opened this issue Nov 1, 2019 · 6 comments
Closed

false positive in style checker, checking casts #781

ghost opened this issue Nov 1, 2019 · 6 comments
Labels

Comments

@ghost
Copy link

ghost commented Nov 1, 2019

The following unittest (in std.format) was rejected by the style checker:

@safe pure unittest
{
    enum A { one, two, three }
    
    string t2 = format("[%10s] [%-10s]", cast(A) 10, cast(A) 10);
    assert(t2 == "[ cast(A)10] [cast(A)10 ]");
}

The problem is the cast(A)10 inside the string.

@Hackerpilot
Copy link
Collaborator

I just built D-Scanner from source and ran it on that code snippet with all checks enabled. The only message that I got was test.d(6:5)[warn]: An assert should have an explanatory message. Is that what you're talking about?

@ghost
Copy link
Author

ghost commented Nov 6, 2019

No. The snippet is taken from Phobos, currently line 4542. When I run

make -f posix.mak style

I get the following message:

Enforce space after cast(...)
grep -nrE '[^"]cast([^)]?)[[:alnum:]]' $(find etc std -name '.d') ; test $? -eq 1
std/format.d:4542: assert(t2 == "[ cast(A)10] [cast(A)10 ]");

I asked, where to report this bug and was first pointed to bugzilla, and there someone said, I should post it here... But maybe it's still the wrong place...

@Hackerpilot
Copy link
Collaborator

That line of the makefile isn't even calling dscanner. It's calling grep. Who asked you to report this here? I think they're confused.

@PetarKirov
Copy link
Member

PetarKirov commented Nov 7, 2019

Hi @berni44 I hope I haven't confused you. The only line of code that needs fixing is the grep regex here:
https://github.com/dlang/phobos/blob/bd31de4f5cdbd89723b299e7fc77101597f3f1da/posix.mak#L588

@ghost
Copy link
Author

ghost commented Nov 7, 2019

@PetarKirov So it should actually be a phobos bugreport? (I don't know, how to fix that line.)

@Hackerpilot Seb pointed me here: https://issues.dlang.org/show_bug.cgi?id=20343

@PetarKirov
Copy link
Member

Yes. I guess Seb didn't see the error message and assumed that the error was coming from DScanner, while it's just the grep line from the posix.mak file.

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

No branches or pull requests

2 participants