Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated formatting #413

Open
rjshae opened this issue Feb 2, 2019 · 2 comments
Open

Automated formatting #413

rjshae opened this issue Feb 2, 2019 · 2 comments

Comments

@rjshae
Copy link
Contributor

rjshae commented Feb 2, 2019

It would be useful if the formatting of the submitted content could automated. Machines are often much better than people at that sort of thing, and automating the process would allow more time to focus on actual coding. Even a format checker that could be run during testing (and prior to a commit) would be helpful. Thanks.

@DrMcCoy
Copy link
Member

DrMcCoy commented Feb 2, 2019

We have a config file for uncrustify in our repo: https://github.com/xoreos/xoreos/blob/master/.uncrustifyrc , which should be able to get you there most of the way.

I haven't really tested it extensively, though, so it might need some tweaking. Pull requests welcome ;)

As for other checks, there is an open "we should investigate this" issue here, for potentially using GitHub Actions (still in beta, I think): #390

@rjshae
Copy link
Contributor Author

rjshae commented Feb 2, 2019

Thanks. I gave it a try with the .uncrustifyrc, and it had an error:

$ ~/uncrustify.exe --check -c ~/.uncrustifyrc -f ~/xoreos/src/engines/nwn2/area.cpp Parsing: C:~/xoreos/src/engines/nwn2/area.cpp as language CPP C:~/.uncrustifyrc:729: unknown symbol 'align_number_left' FAIL: C:~/xoreos/src/engines/nwn2/area.cpp (File size changed from 16671 to 16634)

After correction:

`$ ~/uncrustify.exe -c ~/.uncrustifyrc -f /xoreos/src/engines/nwn2/area.cpp -o test.cpp
Parsing: C:
/xoreos/src/engines/nwn2/area.cpp as language CPP
$ diff ~/xoreos/src/engines/nwn2/area.cpp test.cpp
125c125
< return (_flags & (1 << 2));

  return _flags & (1 << 2);

135c135
< return (_flags & 1);

  return _flags & 1;

142c142
< const Common::UString &Area::getResRef() {

const Common::UString&Area::getResRef() {
146c146
< const Common::UString &Area::getName() {


const Common::UString&Area::getName() {
150c150
< const Common::UString &Area::getDisplayName() {


const Common::UString&Area::getDisplayName() {
193a194

248a250

288a291

364c367
< uint32 ambientDay = props.getUint("AmbientSndDay" , Aurora::kStrRefInvalid);

  uint32 ambientDay   = props.getUint("AmbientSndDay", Aurora::kStrRefInvalid);

367c370
< _ambientDay = ambientSound.getRow(ambientDay ).getString("Resource");

  _ambientDay   = ambientSound.getRow(ambientDay).getString("Resource");

370c373
< uint32 ambientDayVol = CLIP(props.getUint("AmbientSndDayVol" , 127), 0, 127);

  uint32 ambientDayVol   = CLIP<uint32>(props.getUint("AmbientSndDayVol", 127), 0, 127);

373c376
< _ambientDayVol = 1.25f * (1.0f - (1.0f / powf(5.0f, ambientDayVol / 127.0f)));

  _ambientDayVol   = 1.25f * (1.0f - (1.0f / powf(5.0f, ambientDayVol / 127.0f)));

381,382c384,385
< setMusicDayTrack (props.getUint("MusicDay" , Aurora::kStrRefInvalid));
< setMusicNightTrack(props.getUint("MusicNight" , Aurora::kStrRefInvalid));

  setMusicDayTrack  (props.getUint("MusicDay", Aurora::kStrRefInvalid));
  setMusicNightTrack(props.getUint("MusicNight", Aurora::kStrRefInvalid));

420c423
< readTint(t, "WallTint" , tile.wallTint);

  readTint(t, "WallTint",  tile.wallTint);

432c435
< int tileVar = t.getUint("Variation") + 1;

          int tileVar = t.getUint("Variation") + 1;

479,480c482,483
< if (!t->model)
< throw Common::Exception("Can't load tile model "%s"", t->modelName.c_str());

          if (!t->model)
                  throw Common::Exception("Can't load tile model \"%s\"", t->modelName.c_str());

567c570
< if (e->type == Events::kEventMouseMove) { // Moving the mouse

          if (e->type == Events::kEventMouseMove) // Moving the mouse

569c572
< } else if (e->type == Events::kEventMouseDown) { // Clicking

          else if (e->type == Events::kEventMouseDown) { // Clicking

644a648

`

Looks like it may need some tweaking.

The formatting above is squirrely, unforunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants