Skip to content

Coding guidelines #880

@m-weigand

Description

@m-weigand

Feature Request

This issue is aimed at discussing if the following items are worth pursuing in the documentation. Please feel free to close if unimportant. Otherwise I will be happy to propose corresponding changes later on.

Having finally found https://github.com/gimli-org/gimli/blob/dev/doc/community/development/guidelines.md, the following questions came up:

  • I think this should be directly linked in the contributing.md file in the top level of the repository
  • There is no mentioning of any style guide for the code c++ parts of pygimli. Did you follow a specific guideline, or could imagine proposing one?
  • Personally, I am a big fan of short lines (80 or 100 characters per line). I think pep8 proposes a soft limit of 80 characters, but maybe a 100 char. limit would be more appropriate? Maybe this could be a soft guideline, which should be followed, but is not necessarily enforced? Conversion could then be done later in drive-by edits.
  • Another issue that came up is: Line endings:
    Looking at https://github.com/gimli-org/gimli/blob/dev/.gitattributes it seems that there is a certain preference for windows-based CRLF line endings. If yes, I think this should also be properly embedded into the guidelines linked above.
    One questions would be why certain files (e.g., .cpp/.c files) are left "as is" (see .gitattributes). I would suggest to homogeneously use crlf as the line ending of choice for storing, and conversion to local line endings via .gitattributes.

Whlie I am not yet sure to what extend this is a result of my local (linux-based) checkout, a quick check of the repository shows a very inhomogeneous landscape in terms of line endings (first nr is dos line endings, second one unix line endings, third one mac line endings):

gimli$ find . -name "*.py" -exec dos2unix -i {} \; | tr -s " " | cut -f 1-4 -d " " | numsum -c -x 2,3,4
65377 80866 2
gimli$ find . -name "*.cpp" -exec dos2unix -i {} \; | tr -s " " | cut -f 1-4 -d " " | numsum -c -x 2,3,4
0 26124 0
gimli$ find . -name "*.md" -exec dos2unix -i {} \; | tr -s " " | cut -f 1-4 -d " " | numsum -c -x 2,3,4
3208 632 0

While not really an issue for developing/working with pygimli, I think having clear rules promotes code health.

It seems as if files were commited with different line endings, as evident by git ls-files --eol:

[...]
i/lf    w/lf    attr/text eol=crlf    	pygimli/utils/hankel.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/utils/ipcserver.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/utils/postinversion.py
i/lf    w/crlf  attr/text eol=crlf    	pygimli/utils/sparseMat2Numpy.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/utils/streams.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/utils/units.py
i/lf    w/crlf  attr/text eol=crlf    	pygimli/utils/utils.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/viewer/__init__.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/viewer/mpl/__init__.py
i/lf    w/crlf  attr/text eol=crlf    	pygimli/viewer/mpl/boreholes.py
i/lf    w/crlf  attr/text eol=crlf    	pygimli/viewer/mpl/colorbar.py
i/lf    w/crlf  attr/text eol=crlf    	pygimli/viewer/mpl/dataview.py
i/lf    w/lf    attr/text eol=crlf    	pygimli/viewer/mpl/matrixview.py
i/lf    w/lf    attr/text eol=crl
[...]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions