pcdshub / pytmc

Generate EPICS IOCs and records from TwinCAT projects - along with many TwinCAT project tools
https://pcdshub.github.io/pytmc/
Other
10 stars 11 forks source link

ENH: add pragma linter utility #116

Closed klauer closed 5 years ago

klauer commented 5 years ago

Pragmas in TwinCAT are syntactically strange and difficult to type, and TwinCAT is rather specific about what it's looking for - silently ignoring the pragma altogether if it doesn't match up.

So, the idea here is to give a tool to lint the project to find pragma errors before they get further down the line.

I'm not 100% sure about the regex given here, but it at least caught some problematic ones in my local tests.

Example:

$ pytmc pragmalint ~/Repos/L2SI-Vacuum-Lib/L2SIVacuumLib.tsproj 
PLC Project (1): L2SIVacuum
===========================

ERROR:pytmc.bin.pragmalint:Linter error:
DUTs/Valves/ST_VGC.TcDUT:line 54:     {attribute 'pytmc' :=
        'pv: Ext_ILK_OK ;
        field: ZNAM NOT OK ;
        field: ONAM OK ;
        io: i ;
    '}
ERROR:pytmc.bin.pragmalint:Linter error:
DUTs/Valves/ST_VGC.TcDUT:line 134:     {attribute 'pytmc' :=
        'pv: POS_STATE ;
        type: mbbi ;
        field: ZRST OPEN ;
        field: ONST CLOSED ;
        field: TWST MOVING ;
        field: THST INVALID ;
        io: i
        '}
ERROR:pytmc.bin.pragmalint:Linter error:
POUs/Functions/Gauges/FB_MKS_937B.TcPOU:line 13:     {attribute 'pytmc' := pv: '}
codecov-io commented 5 years ago

Codecov Report

Merging #116 into master will increase coverage by 1.72%. The diff coverage is 86.62%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #116      +/-   ##
=========================================
+ Coverage   74.58%   76.3%   +1.72%     
=========================================
  Files          15      16       +1     
  Lines        1633    1760     +127     
=========================================
+ Hits         1218    1343     +125     
- Misses        415     417       +2
Impacted Files Coverage Δ
pytmc/bin/pytmc.py 80% <ø> (ø) :arrow_up:
pytmc/bin/summary.py 88.67% <100%> (+0.49%) :arrow_up:
pytmc/pragmas.py 97.72% <100%> (+0.02%) :arrow_up:
pytmc/bin/pragmalint.py 84.8% <84.8%> (ø)
pytmc/bin/util.py 60.52% <90.9%> (+41.77%) :arrow_up:
pytmc/parser.py 83.61% <0%> (+0.76%) :arrow_up:
pytmc/bin/xmltranslate.py 92% <0%> (+4%) :arrow_up:
pytmc/bin/stcmd.py 70.9% <0%> (+10%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6a35be0...f4cccda. Read the comment docs.