www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dub lint

reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Sep 15 2022
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Sep 15 2022
parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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
Sep 15 2022
parent reply =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
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 [<package>[ <version-spec>]] [<options...>] [-- <application arguments...>] .. .. --config=VALUE Use the given configuration file. .. .. -c --config=VALUE Builds the specified configuration. .. .. ``` Kind regards, Christian
Sep 15 2022
next sibling parent reply =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
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 [<package>[ <version-spec>]] [<options...>] [--
 <application arguments...>]
 ..
 ..
        --config=VALUE    Use the given configuration file.
 ..
 ..
    -c  --config=VALUE    Builds 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
Sep 15 2022
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
https://github.com/dlang/dub/issues/2483
Sep 15 2022
parent =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
On 16.09.22 02:23, rikki cattermole wrote:
 
 https://github.com/dlang/dub/issues/2483
Also the double --config option is already in a bugreport (quite old), but not fixed as far as i can see: https://github.com/dlang/dub/issues/1940 Kind regards, Christian
Sep 16 2022
prev sibling parent =?UTF-8?Q?Christian_K=c3=b6stlin?= <christian.koestlin gmail.com> writes:
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 [<package>[ <version-spec>]] [<options...>] [-- <application arguments...>] .. ..       --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
Sep 15 2022