codefori / vscode-rpgle

RPGLE language tools for VS Code
MIT License
39 stars 20 forks source link

Reformat Document: Lint problem with "Expressions must be surrounded by brackets." #251

Closed SJLennon closed 1 year ago

SJLennon commented 1 year ago

This short sample shows two problems at lines 18 and 19: image

If I run Format Document then it creates several more errors: image

That appears to be because of the change in line 18 where it has put the whole line in brackets, not just the expression.
If I move the brackets to surround the expression then things look much better: image

Here's the complete code:

**free
ctl-opt debug  option(*nodebugio: *srcstmt) dftactgrp(*no) actgrp(*caller)
main(Main);
dcl-s STDDSC  packed(5:2) inz(9.0); //from Item Master External  DS
dcl-c THE_DEFAULT_DISCOUNT 9;
dcl-proc Main;
    dsply %char(CalcDiscount(1000));
    return;
end-proc;
dcl-proc CalcDiscount ;
    dcl-pi CalcDiscount packed(7:2);
        iCost packed(7:2) value;
    end-pi;
    // @rpglint-skip
    STDDSC = The_Default_Discount;
    if (wkChar = *blanks);
    endif;
    if (iCost >= 10000);
        wkDisc = (iCost*BigDisc)/100;
    Else;
        wkDisc = (iCost*STDDSC)/100;  // << Error here <<
    endif;
    Return wkDisc;
end-proc;

⚠️ REMOVE THIS LINE AND ANY SENSITIVE INFORMATION BELOW! ⚠️

Context Version
Code for IBM i version 2.1.1
Visual Studio Code version 1.81.1
Operating System win32_x64
Active extensions ``` Code for IBM i Walkthroughs (vscode-ibmi-walkthroughs): 0.3.1 Db2 for IBM i (vscode-db2i): 0.4.0 Emmet (emmet): 1.0.0 Error Lens (errorlens): 3.13.0 Extension Authoring (extension-editing): 1.0.0 Git (git): 1.0.0 Git Base (git-base): 1.0.0 GitHub (github): 0.0.1 GitHub Authentication (github-authentication): 0.0.2 GitLens — Git supercharged (gitlens): 14.2.1 IBM i Notebooks (vscode-ibmi-notebooks): 0.0.6 JSON Language Features (json-language-features): 1.0.0 Merge Conflict (merge-conflict): 1.0.0 Microsoft Account (microsoft-authentication): 0.0.1 NPM support for VS Code (npm): 1.0.1 Node Debug Auto-attach (debug-auto-launch): 1.0.0 Overtype (overtype): 0.5.0 RPGLE (vscode-rpgle): 0.21.3 TypeScript and JavaScript Language Features (typescript-language-features): 1.0.0 WSL: Recommender (remote-wsl-recommender): 0.0.19 ```

Remote system |Setting|Value| |-|-| |IBM i OS|V7R5M0| |Tech Refresh|n/a| |CCSID|37| |SQL|Enabled |Source dates|Disabled ### Enabled features |/QOpenSys/pkgs/bin|/usr/bin|/QSYS.lib/LENNONS2.lib|/QSYS.LIB|/QIBM/ProdData/IBMiDebugService/bin| |-|-|-|-|-| |bash|attr|GENCMDXML.PGM|QZDFMDB2.PGM|startDebugService.sh| |chsh|iconv|GETNEWLIBL.PGM||| |git|setccsid|||| |grep||||| |ls||||| |md5sum||||| |sort||||| |stat||||| |tar||||| |tn5250|||||
Shell env ```bash BUILDLIB=LENNONSB CURLIB=LENNONSB HOME=/home/LENNONS LIB1=LENNONSB LIBLS=LENNONS1 LENNONSB QGPL QTEMP QIWS LOGIN=lennons LOGNAME=lennons MAIL=/var/spool/mail/lennons OLDPWD=/home/LENNONS PASE_USRGRP_LIMITED=N PATH=/QOpenSys/pkgs/bin:/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin PWD=/home/LENNONS SHELL=/QOpenSys/pkgs/bin/bash SHLVL=1 SSH_CLIENT=71.63.120.199 57589 2222 SSH_CONNECTION=71.63.120.199 57589 185.113.5.134 2222 TZ=0 USER=lennons USERNAME=lennons _=/QOpenSys/pkgs/bin/env ```
Variants ```json { "american": "#@$", "local": "#@$" } ```
Errors ```json [ { "command": "system \"CRTLIB LIB(LENNONS2) TEXT('Code for i temporary objects. May be cleared.')\"", "code": 255, "stderr": "CPD0032: Not authorized to command CRTLIB in library *LIBL.\nCPF0006: Errors occurred in command.", "cwd": "/home/LENNONS" }, { "command": "system \"DLTOBJ OBJ(LENNONS2/O_*) OBJTYPE(*FILE)\"", "code": 255, "stderr": "CPF2125: No objects deleted.", "cwd": "/home/LENNONS" }, { "command": "/QOpenSys/usr/bin/qsh", "code": 1, "stderr": "CPF3026: Not authorized to file QSOURCE in library QGPL.\nCPF3014: No file specified as QSOURCE in *LIBL can be displayed.", "cwd": "/home/LENNONS" } ] ```
worksofliam commented 1 year ago

Released with 0.21.4.