Re: dub lint

2022-09-15 Thread rikki cattermole via Digitalmars-d-learn



https://github.com/dlang/dub/issues/2483


Re: dub lint

2022-09-15 Thread Christian Köstlin via Digitalmars-d-learn

On 16.09.22 01:14, Christian Köstlin wrote:

On 16.09.22 00:14, Ali Çehreli wrote:

On 9/15/22 15:04, Ali Çehreli wrote:

 > Is there a way to silence specific 'dub lint' warnings?

Answering myself, I don't think it's possible but luckily my catching 
an Error was in unittests only so I can do either of the following to 
skip unittest code when linting:


a) Pass --skipTests to dscanner (what 'dub lint' runs behind the 
scenes) along with --styleCheck, which --skipTests requires


   dub lint -- --skipTests --styleCheck

b) Pass --styleCheck indirectly through 'dub lint', which has its own 
spelling for it :), but --skipTests is still required of course:


   dub lint --style-check -- --skipTests

Ali

There is `dub run dscanner -- --defaultConfig` which creates a default 
config in `~/.config/dscanner/dscanner.ini` (for linux and osx). There 
one can disable only the checks for bad exception handling

```
; Check for poor exception handling practices
exception_check="disabled"
```
and then its possible to move this file e.g. to the project folder and 
use in with `dub lint --config=dscanner.ini` ...

interestingly `dub lint --help` shows two different options for `--config`:

```
dub lint --help
USAGE: dub lint [[@]] [] [-- 
]

..
..
   --config=VALUE    Use the given configuration file.
..
..
   -c  --config=VALUE    Builds the specified configuration.
..
..

```

Kind regards,
Christian
p.s. phobos for example includes its own dscanner.ini file in 
https://github.com/dlang/phobos/blob/master/.dscanner.ini







Re: dub lint

2022-09-15 Thread Ali Çehreli via Digitalmars-d-learn

On 9/15/22 16:14, Christian Köstlin wrote:

> There is `dub run dscanner -- --defaultConfig` which creates a default
> config in `~/.config/dscanner/dscanner.ini` (for linux and osx).

Thanks! I love such features. It is so useful for a program to write out 
its configuration file. (My tools did that too.)


> interestingly `dub lint --help` shows two different options for 
`--config`:

>
> ```
> dub lint --help
> USAGE: dub lint [[@]] [] [--
> ]
> ..
> ..
>--config=VALUEUse the given configuration file.
> ..
> ..
>-c  --config=VALUEBuilds the specified configuration.

Neither of which is obvious to the newcommer at all. Not one bit! Even 
though I knew dscanner was the program 'dub lint' uses (perhaps because 
I noticed the message as it was being installed?) I did not think even 
once that 'dub lint's --config would refer to 'dscanner's config.


As a dub user, I wouldn't know to go to a random program's web site. 
Even 'dub lint' doesn't mention dscanner: 
https://dub.pm/commandline.html#lint


Ali



Re: dub lint

2022-09-15 Thread Christian Köstlin via Digitalmars-d-learn

On 16.09.22 00:14, Ali Çehreli wrote:

On 9/15/22 15:04, Ali Çehreli wrote:

 > Is there a way to silence specific 'dub lint' warnings?

Answering myself, I don't think it's possible but luckily my catching an 
Error was in unittests only so I can do either of the following to skip 
unittest code when linting:


a) Pass --skipTests to dscanner (what 'dub lint' runs behind the scenes) 
along with --styleCheck, which --skipTests requires


   dub lint -- --skipTests --styleCheck

b) Pass --styleCheck indirectly through 'dub lint', which has its own 
spelling for it :), but --skipTests is still required of course:


   dub lint --style-check -- --skipTests

Ali

There is `dub run dscanner -- --defaultConfig` which creates a default 
config in `~/.config/dscanner/dscanner.ini` (for linux and osx). There 
one can disable only the checks for bad exception handling

```
; Check for poor exception handling practices
exception_check="disabled"
```
and then its possible to move this file e.g. to the project folder and 
use in with `dub lint --config=dscanner.ini` ...

interestingly `dub lint --help` shows two different options for `--config`:

```
dub lint --help
USAGE: dub lint [[@]] [] [-- 
]

..
..
  --config=VALUEUse the given configuration file.
..
..
  -c  --config=VALUEBuilds the specified configuration.
..
..

```

Kind regards,
Christian




Re: dub lint

2022-09-15 Thread Ali Çehreli via Digitalmars-d-learn

On 9/15/22 15:04, Ali Çehreli wrote:

> Is there a way to silence specific 'dub lint' warnings?

Answering myself, I don't think it's possible but luckily my catching an 
Error was in unittests only so I can do either of the following to skip 
unittest code when linting:


a) Pass --skipTests to dscanner (what 'dub lint' runs behind the scenes) 
along with --styleCheck, which --skipTests requires


  dub lint -- --skipTests --styleCheck

b) Pass --styleCheck indirectly through 'dub lint', which has its own 
spelling for it :), but --skipTests is still required of course:


  dub lint --style-check -- --skipTests

Ali



Re: dub lint

2022-09-15 Thread Ali Çehreli via Digitalmars-d-learn

On 9/15/22 14:32, Ali Çehreli wrote:

> (However, like all linters it's not perfect but I still like having that
> power.)

The following code is flagged because it catches Error:

unittest
{
try
{
assert(false);
}
catch (Error)
{
// Cool...
}
}

[warn]: Catching Error or Throwable is almost always a bad idea.

Is there a way to silence specific 'dub lint' warnings? For example, the 
code above is actually similar to assertThrown!Error, which knows what 
it's doing. :)


  https://dub.pm/commandline.html#lint

Ali



dub lint

2022-09-15 Thread Ali Çehreli via Digitalmars-d-learn
I've always thought of dub as a package manager and a build tool. But it 
actually makes it easy to use other tools:


- dub lint: Runs some checks on your project. What I liked is how it 
removed the need to figure out how to install dscanner, which it uses 
behind the scenes. It installed dscanner and simply ran it. Cool... 
(However, like all linters it's not perfect but I still like having that 
power.)


- dub dustmite: I haven't actually tried this but dub's help with using 
dusmite sounds great.


Ali


Re: Does the GC prioritize same-class when looking for things to free?

2022-09-15 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/15/22 1:12 PM, cc wrote:
Why is Foo never deallocated here? (`DMD32 D Compiler v2.099.0-dirty` 
win64)


In answer to your title question, no. It does not prioritize anything. 
If it thinks something is ready to be freed, it is freed. If it thinks 
something is not ready to be freed, it is not freed.


So why is it not deallocated? There is no requirement for a specific 
piece of garbage to be collected at any specific time. Maybe something 
is referring to it on a register, and that register is still present? 
Maybe it's stored it somewhere on the stack? Maybe there's a false 
positive from a stack variable that isn't a pointer? For whatever 
reason, the GC still thinks it's alive.


People pull their hair out a lot trying to explain why the GC does or 
does not free something. Sometimes it just works one way on some 
environments, and differently on others.


I'd recommend just forgetting trying to prove whether the GC works or 
not, or that it works a specific way. Unless you are having a specific 
problem with memory leaks or things that are being freed that shouldn't 
be, don't worry about it.


-Steve


Does the GC prioritize same-class when looking for things to free?

2022-09-15 Thread cc via Digitalmars-d-learn
Why is Foo never deallocated here? (`DMD32 D Compiler 
v2.099.0-dirty` win64)

```d
class Foo {
string s;
static size_t count, alloced, dealloced;
this() {
"+Foo".writeln;
count++;
alloced++;
}
~this() {
"~Foo".writeln;
count--;
dealloced++;
}
}
class Bar {
string s;
static size_t count, alloced, dealloced;
this() { count++; alloced++; }
~this() { count--; dealloced++; }
}
void main() {
	static assert(__traits(classInstanceSize, Foo) == 
__traits(classInstanceSize, Bar));


GC.collect();
writeln(GC.stats.usedSize, " START");
{
new Foo;
}
foreach (i; 0 .. 4_000_000) {
new Bar;
if (Foo.dealloced)
break;
}
writeln(GC.stats.usedSize);

writeln("Foo: ", Foo.count);
	writefln("Bar: %,d (%,d - %,d)", Bar.count, Bar.alloced, 
Bar.dealloced);


GC.collect();
GC.minimize();
writeln(GC.stats.usedSize, " END");
```

```
0 START
+Foo
89632
Foo: 1
Bar: 2,800 (4,000,000 - 3,997,200)
64 END
~Foo
```


Re: can not take const struct member address at CTFE , is this a bug?

2022-09-15 Thread test123 via Digitalmars-d-learn

On Thursday, 15 September 2022 at 11:33:43 UTC, Dennis wrote:

On Thursday, 15 September 2022 at 04:13:56 UTC, test123 wrote:

I hope we have github bugs.


It's being worked on.


glad to know we are move into github.

Please help me create a bug report if who has free time and 
bugs account.


Here you go: https://issues.dlang.org/show_bug.cgi?id=23336


thanks for the help.


Re: can not take const struct member address at CTFE , is this a bug?

2022-09-15 Thread Dennis via Digitalmars-d-learn

On Thursday, 15 September 2022 at 04:13:56 UTC, test123 wrote:

I hope we have github bugs.


It's being worked on.

Please help me create a bug report if who has free time and 
bugs account.


Here you go: https://issues.dlang.org/show_bug.cgi?id=23336