worldbank / stata-linter

MIT License
29 stars 13 forks source link

Some errors are not detected #56

Closed kbjarkefur closed 1 year ago

kbjarkefur commented 2 years ago

This file should include all bad practices that should be detected.


    * hard tab
    ieboilstart, version(13.1)

    *One letter local
    forvalues i = 1/3 {
        di "foo"
    }

    *Non standard whitespace in side curly brackets
    forvalues index = 1/3 {
    gen this_cluster = tmt
    } 

*No indentation after three slashes
iebaltab weight price, ///
grpvar(tmt) pairoutput("p") ftestoutput("p") replace 

    *Missing whitespace around operators
    gen tmt = (runiform()<.5)
    gen num = 4-2

    *Implicit logic
    if `LINTER_USED' {
        di "ehk"
    }

    *Delimiter
    #delimit ;
    iebaltab weight price, 
    grpvar(tmt) pairoutput("p") ftestoutput("p") replace ;
    #delimit cr

    *Working directory
    cd "C:/Users/wb462869/GitHub/ietoolkit"

    * Line too long
    iebaltab weight price   , grpvar(tmt)      pairoutput("p") ftestoutput("p")  replace savecsv("${ietoolkit}/run/output/iebaltab/iebt_csv")  savexlsx("${ietoolkit}/run/output/iebaltab/iebt_xlsx")

    * Global no curly brackets
    qui do "$ietoolkit/src/ado_files/iebaltab.ado"

    * Use of . where missing() is appropriate:  
    replace tmt = 10231 if tmt >= .

    *Potential omission of missing values in expression: 
    replace tmt = 10231 if tmt == .

    *Baclash
    global  ietoolkit "C:\Users\wb123456\GitHub\ietoolkit"

    * ~
    replace tmt = 10231 if ~= 232   

But only the following bad practices are flagged:

image