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

SQF Lint Cleanup Pass #5157

Merged
merged 8 commits into from
May 14, 2017
Merged

SQF Lint Cleanup Pass #5157

merged 8 commits into from
May 14, 2017

Conversation

PabstMirror
Copy link
Contributor

@PabstMirror PabstMirror commented May 13, 2017

Did a quick pass with the SQF Lint tool. (https://github.com/LordGolias/sqf)

Most are just private cleanups which aren't a big deal, but it did find some actual errors.

  • Fixed: getDoorTurrets (Not used, was broken, could drop?)
  • Fixed: getMGRSdata (Was ignoring getMapData altitude)
  • Fixed: throttledPublicVariable (Not used anywhere, should probably test if we use it in the future)
  • Fixed: handleRespawn (Using bad var name, escort setVar would not be reset)
  • Fixed dropNozzle
  • magazineRepackProgress (magically not broken because progressbar uses same var name)
  • readWeaponDataFromConfig (same thing, _weapon always existed from upper scope)

@PabstMirror PabstMirror added kind/bug-fix Release Notes: **FIXED:** kind/cleanup Release Notes: **CHANGED:** labels May 13, 2017
@PabstMirror PabstMirror added this to the 3.10.0 milestone May 13, 2017
@@ -115,7 +115,7 @@ addMissionEventHandler ["Draw3D", { // Blue is predicted before throw, red is re
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [0,0,1,1], _newTrajAGL, 1, 1, 0, "", 2];
} forEach GVAR(predictedPath);
{
_newTrajAGL = _x;
private _newTrajAGL = _x;
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,0,0,1], _newTrajAGL, 1, 1, 0, "", 2];
Copy link
Member

Choose a reason for hiding this comment

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

Could probably just use _x here without _newTrajAGL

@jonpas
Copy link
Member

jonpas commented May 13, 2017

Oh, commy also opened the PRs for getDoorTurret and publicVariable. :D

@commy2
Copy link
Contributor

commy2 commented May 13, 2017

missed this 🤦‍♀️

@commy2
Copy link
Contributor

commy2 commented May 13, 2017

This PR closes #5159 and #5160.

@LordGolias
Copy link
Contributor

LordGolias commented May 13, 2017

Glad to know this was so helpful for ACE! Please share relevant issues to the SQF parser github page please so I can improve it.


for root, dirnames, filenames in os.walk('../addons' + '/' + args.module):
for filename in fnmatch.filter(filenames, '*.sqf'):
sqf_list.append(os.path.join(root, filename))
Copy link
Member

Choose a reason for hiding this comment

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

2 space instead of 4 space indentation.

for filename in sqf_list:
warnings, errors = analyze(filename)
all_warnings = all_warnings + warnings
all_errors = all_errors + errors
Copy link
Member

Choose a reason for hiding this comment

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

+=

print("{}:".format(filename))
for e in exceptions:
if (e.message.startswith("error")):
errors = errors + 1
Copy link
Member

Choose a reason for hiding this comment

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

+=

if (e.message.startswith("error")):
errors = errors + 1
else:
warnings = warnings + 1
Copy link
Member

Choose a reason for hiding this comment

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

+=


for filename in sqf_list:
warnings, errors = analyze(filename)
all_warnings = all_warnings + warnings
Copy link
Member

Choose a reason for hiding this comment

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

+=

except SQFParserError as e:
print("{}:".format(filename))
writer.write(' [%d,%d]:%s\n' % (e.position[0], e.position[1] - 1, e.message))
return 0, -1
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason this returns a -1 for number of errors? I feel like it should be 0, but perhaps I'm missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-1 used to mean error, but I changed it, thanks for catching

@jonpas
Copy link
Member

jonpas commented May 14, 2017

SQF Lint now has directory analyze option https://github.com/LordGolias/sqf/blob/92130853eadeec524ca641b2c4bde34f5fc18f52/sqflint.py with help of @PabstMirror 's script. It doesn't count the amount of warnings and errors as of now though.

@PabstMirror PabstMirror merged commit bfd3695 into master May 14, 2017
@PabstMirror PabstMirror deleted the lintPass1 branch May 14, 2017 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix Release Notes: **FIXED:** kind/cleanup Release Notes: **CHANGED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants