krober10nd / SeismicMesh

2D/3D serial and parallel triangular mesh generation tool for finite element methods.
https://seismicmesh.readthedocs.io/
GNU General Public License v3.0
126 stars 32 forks source link

consider using code formats #27

Closed nschloe closed 4 years ago

nschloe commented 4 years ago

There's the common Python formatter black; from what I see your code is already it. Also: isort for sorting the imports, and: flake8. In my project Makefile, I usually have

format:
>~isort .
>~black .
>~blacken-docs README.md

lint:
>~isort --check .
>~black --check .
>~flake8 .

Perhaps one of them is useful to you, perhaps not. Perhaps there's something similar for the C++ part of your code.

krober10nd commented 4 years ago

Interesting. I'm not familiar with the Makefile for a Python package. I see one of yours here https://github.com/nschloe/pygalmesh/blob/master/Makefile

When is this file used?

krober10nd commented 4 years ago

Looks like it provides macros to accelerate common tasks.

nschloe commented 4 years ago

When is this file used?

Indeed, it's just for me to remember the commands for formatting, tagging, uploading etc. It's basically a glorified txt-file. That's a personal preference though, everyone does that differently I guess.

krober10nd commented 4 years ago

It's seems very useful because, I too am constantly forgetting these commands.

I'll look into something similar for the C++

nschloe commented 4 years ago

One big plus of using formatting (and optionally advertising it with a badge or so) is that people see that you though about formatting and the code doesn't look horrible. It gives a good first impression and encourages contributions.

krober10nd commented 4 years ago

Yea, that's definitely true. Working with a good open source project like FEINCS/Firedrake team too has showed me better ways to do things (like what you suggest) that I unfortunately wasn't exposed to earlier on.

krober10nd commented 4 years ago

Ok, I set up a Makefile and applied it throughout. This will definitely help when I go to add new features etc. later on. For c++, I used clang-format which seems to have improved the clarity of things imo.