Skip to content

Conversation

@wilzbach
Copy link
Member

I think we should try putting the linting off to a real bot.
This PR adds a execution of dscanner.

We probably want to play with this for a while, maybe disable some checks or fix the codebase until we set the --enforce flag, which will exit the CI with an error.
Currently it outputs many messages, see e.g. here

Other

  • It is only run on travis subbuild - hence the version check (I reused it for the s3 check)
  • As there is no binary release of dscanner, I created releases.dlang.io (a s3 bucket to which I will upload such release) - this speeds up the build! Otherwise there is still dub fetch & dub run.

@codecov-io
Copy link

Current coverage is 98.17%

Merging #88 into master will increase coverage by +0.05% as of ec51871

@@            master     #88   diff @@
======================================
  Files            7       7       
  Stmts         2500    2580    +80
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit           2453    2533    +80
  Partial          0       0       
  Missed          47      47       

Review entire Coverage Diff as of ec51871

Powered by Codecov. Updated on successful CI builds.

@9il
Copy link
Member

9il commented Apr 14, 2016

I don't think dscanner is good enought

@wilzbach
Copy link
Member Author

I don't think dscanner is good enought

AFAIK it's the best tool out there and we can just disable the warnings that we don't like.
In my opinion a linting is better than no linting?

@9il
Copy link
Member

9il commented Apr 14, 2016

ping me when you would think PR is ready

@wilzbach wilzbach force-pushed the dscanner branch 8 times, most recently from 134a9a1 to 5599748 Compare April 14, 2016 14:04
@wilzbach
Copy link
Member Author

@9il I think I am getting somewhere, but for the remaining issues I would like to hear your opinion and help. I do consider static analysis of code important as it can prevent a couple of errors and it ensures that the codes sticks to a style guide - the latter being the main reason for my attempt here.
Dscanner checks for a lot of stuff - have a look at the .dscanner.ini. It was really helpful to realize that the new combinatorics module didn't document itself properly.

You can run it locally with:

dub fetch dscanner --version=~master
dub run dscanner -- --config .dscanner.ini --styleCheck source

Or install the dscanner-git package on Arch Linux. I recommend storing the binary somewhere as you avoid the dub checking and can pass the spammy error log to dev/null. I use

dscanner --config .dscanner.ini --styleCheck source 2> /dev/null

I grouped them after their warning types, so that it's easier to look at them.
Please do consider that disabling a check because of one or two edge cases results in we no benefit from this help in the future. I still didn't set the --enforce flag, but I plan to do so after we resolved remaining the conflicts below.

Naming style guide

From Phobos: functions + variables in camelCase.

source/mir/las/sum.d(2125:11)[warn]: Function name 'SummationAlgo' does not match style guidelines.
source/mir/las/sum.d(2135:11)[warn]: Function name 'SummationAlgo' does not match style guidelines.
source/mir/ndslice/internal.d(174:21)[warn]: Variable name 'DynamicArrayDimensionsCount' does not match style guidelines.
source/mir/ndslice/internal.d(176:21)[warn]: Variable name 'DynamicArrayDimensionsCount' does not match style guidelines.
source/mir/ndslice/internal.d(256:8)[warn]: Struct name '_Slice' does not match style guidelines.
source/mir/ndslice/slice.d(1042:21)[warn]: Variable name 'PureN' does not match style guidelines.

Subtracting from .length

source/mir/ndslice/selection.d(221:29)[warn]: Avoid subtracting from '.length' as it may be unsigned.
source/mir/ndslice/selection.d(222:29)[warn]: Avoid subtracting from '.length' as it may be unsigned.

Zero-parameter '@Property' function

source/mir/ndslice/selection.d(937:22)[warn]: Zero-parameter '@property' function should be marked 'const', 'inout', or 'immutable'.
source/mir/ndslice/selection.d(979:22)[warn]: Zero-parameter '@property' function should be marked 'const', 'inout', or 'immutable'.
source/mir/ndslice/selection.d(1422:22)[warn]: Zero-parameter '@property' function should be marked 'const', 'inout', or 'immutable'.
source/mir/ndslice/slice.d(1327:14)[warn]: Zero-parameter '@property' function should be marked 'const', 'inout', or 'immutable'.
source/mir/ndslice/slice.d(1374:14)[warn]: Zero-parameter '@property' function should be marked 'const', 'inout', or 'immutable'.
source/mir/ndslice/slice.d(2845:14)[warn]: Zero-parameter '@property' function should be marked 'const', 'inout', or 'immutable'.

'opCmp', 'toHash', 'opEquals', 'opCast', and/or 'toString' should be const

source/mir/ndslice/slice.d(1591:10)[warn]: Methods 'opCmp', 'toHash', 'opEquals', 'opCast', and/or 'toString' are non-const.
source/mir/ndslice/slice.d(1609:10)[warn]: Methods 'opCmp', 'toHash', 'opEquals', 'opCast', and/or 'toString' are non-const.

has method 'opEquals', but not 'toHash'

source/mir/ndslice/slice.d(1027:8)[warn]: 'Slice' has method 'opEquals', but not 'toHash'.

Avoid use of the comma expression

source/mir/ndslice/selection.d(763:66)[warn]: Avoid using the comma expression.

Disabled flags

Moreover I disabled a couple of flags temporarily - I do plan to fix the codebase at a later point and toggle this on, but let's go step by step.

Here's the list with the reason:

  • undocumented public documentation: it correctly realizes that for /// the documentation is undefined. not sure yet whether this is a bug. Should we write /// ditto?
  • "Local imports should specify the symbols being imported to avoid hiding local symbols": there were too many violations.
  • unused variable: issue #326
  • could be immutable: issue #325
  • checks for labels with the same name as variables: issue #323


/// ditto
struct IndexedRoR(Collection, Range)
if (isInputRange!Range)
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 didn't have docs ...

@9il
Copy link
Member

9il commented Apr 14, 2016

Naming style guide

turn off please


static if (canSave!PureRange)
auto save() @property
auto save()
Copy link
Member Author

Choose a reason for hiding this comment

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

@property methods with zero arguments should return const.
Changing this as it still can be used via UCFS

@9il
Copy link
Member

9il commented Apr 14, 2016

I would not merge this until the Phobos merged or you remove changes in ndslice package

@9il
Copy link
Member

9il commented Apr 14, 2016

Please move all changes to separate PR (and without ndslice)

@wilzbach
Copy link
Member Author

@9il I tried to describe why I did some of the changes - hope this helps to understand ;-)
Will separate now.

Forward range, which yields the permutations

See_Also:
$(LREF Permutations), $(LREF dispose)
Copy link
Member Author

Choose a reason for hiding this comment

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

As it is bundled with makePermutations, linking to dispose could be useful to the user

Copy link
Member

Choose a reason for hiding this comment

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

dispose make refer to another dispose

Copy link
Member Author

Choose a reason for hiding this comment

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

dispose make refer to another dispose

Ehm sry - what do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

you have multiple dispose declarations

Copy link
Member Author

Choose a reason for hiding this comment

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

So there is no way to link to the "correct" one?

Copy link
Member

Choose a reason for hiding this comment

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

no way

Copy link
Member Author

Choose a reason for hiding this comment

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

I just tested and if I click on dispose it will get to such a page - is this good enough or should we trust that the unittest does the explanation?

image

Copy link
Member

Choose a reason for hiding this comment

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

this is not good enough

On 15 апр. 2016 г., at 18:08, Sebastian Wilzbach notifications@github.com wrote:

In source/mir/combinatorics/package.d #88 (comment):

@@ -251,6 +300,9 @@ Params:

Returns:
Forward range, which yields the permutations
+
+See_Also:

  • $(LREF Permutations), $(LREF dispose)
    I just tested and if I click on dispose it will get to such a page - is this good enough or should we trust that the unittest does the explanation?

https://cloud.githubusercontent.com/assets/4370550/14567575/5b2cef92-033d-11e6-8fba-96ccd58c8996.png

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub https://github.com/DlangScience/mir/pull/88/files/21c97a5060d40c21e7e415ee78bab94c461e591f#r59898839

@wilzbach
Copy link
Member Author

Hmm it seems that there were still a lot of stuff to do for the combinatorics module - here's a list of what i changed:

  • allocator order for makeCombinations,Repeat,CartesianPower
  • length for permutations (all other collections have this too)
  • unittests for length
  • unittest for invalid input
  • unittest for indexed
  • added const to @property attributes like bool and length
  • reworked the description for `IndexedRoR

@9il
Copy link
Member

9il commented Apr 15, 2016

allocator order for makeCombinations,Repeat,CartesianPower

allocators should be first argumensts

@wilzbach
Copy link
Member Author

allocators should be first argumensts

Yep those had the allocater as last argument

@wilzbach wilzbach added the Style label Apr 15, 2016
@wilzbach wilzbach force-pushed the dscanner branch 5 times, most recently from a505745 to b73e74c Compare April 15, 2016 19:23

For example $(D"AB".combinations(2).array) returns $(D["AB"]).
For example `"AB".combinations(2).array` returns `["AB"]`.

Copy link
Member Author

Choose a reason for hiding this comment

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

should I remove .array here?

Copy link
Member

Choose a reason for hiding this comment

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

remove this example from the docs. And add constraints, that templates are note accepts narrow strings.

@wilzbach
Copy link
Member Author

@9il CI was failing due to an added tests which included the Mallocator - should be fixed now. Any other objections? :)

@wilzbach wilzbach force-pushed the dscanner branch 2 times, most recently from 5ec45b5 to cbf3775 Compare April 15, 2016 22:22
@wilzbach
Copy link
Member Author

remove this example from the docs. And add constraints, that templates are note accepts narrow strings.

I created a module level unittest as an overview over the iterators.
Moreover I realized that indexed from std.range actually needs a random access range and thus corrected all template constraints. A narrow string can't be a random access string :)

@wilzbach
Copy link
Member Author

(rebased to latest master - as we are moving quite fast tonight)

@9il 9il merged commit 2d5d46d into libmir:master Apr 15, 2016
@wilzbach
Copy link
Member Author

Failed to download http://code.dlang.org/packages/libevent/2.0.1+2.0.16.zip: 404 Not Found

why? :(

@9il
Copy link
Member

9il commented Apr 15, 2016

why? :(

Just remove ddox. I don't like vibe.d and ddox ;/

We can use https://github.com/kiith-sa/harbored-mod, it is the best but needs small update. Probably we would need to add macros file from dlang

@wilzbach
Copy link
Member Author

We can use https://github.com/kiith-sa/harbored-mod, it is the best but needs small update.

Okay will send a PR later ;-)

@wilzbach
Copy link
Member Author

Okay will send a PR later ;-)

Hmm seems that we have to fix libdparse first ...
dlang-community/harbored-mod#62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants