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

linting feature request: no single star comments #95

Open
Carus11 opened this issue Jul 22, 2021 · 6 comments
Open

linting feature request: no single star comments #95

Carus11 opened this issue Jul 22, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@Carus11
Copy link

Carus11 commented Jul 22, 2021

Could I request a rule to ensure there are none of those single star comments, basically

* This is what my code does 

Fails, and:

/* This is what my code does */

Passes

@allanbowe allanbowe added the enhancement New feature or request label Jul 22, 2021
@allanbowe
Copy link
Member

allanbowe commented Jul 22, 2021

Hey Carus! I've been thinking about this. Here are the initial test cases I came up with - can you think of any more?

/**
 * Examples of *message; format that SHOULD be caught
 */

/* 1. regular comment */
* some text;

/* 2. multiline comment */
*
multiline
text;

/* multiple asterisks - should start on first */
   *---------------------------------------*
   |  This uses one comment statement      |
   |           to draw a box.              |
   *---------------------------------------*;
   

/* 3. comment at end of statement */
libname x (work); * some text;


/* 4. comment in middle of statement */
run; *walk
; run;

/* 5. comment at start of statement */
*; run;

/* 6.  comment within a comment */
* /* ignored also */ ;

/* 7. In a macro */
%macro x; * %mend;


/**
 * Examples of *message; format that should NOT be caught
 * (this was the first)
 */

/* 2. In a string literal */
data _null_;
  string='no*no;no';
  string="not*this;either";
run;

/* 3. In a %str() block */
%let x=%str(afraid *not; sir);

/* 4. In an nrstr() block */
%let y=%nrstr(try*again;please);

/* 5. In a %put statement */
%put not * today;;

/* 6. As a macro comment */
%* this one is totally normal; 

/* 7. in a LUA proc */
proc lua;
submit;
 -- hi *mum;
endsubmit;
run;

/* 8. in a data step */
data;
  a * b;
  b ** a;
run;

/* 9. sql / fedsql */
proc sql;
  select * from sashelp.cars;
  select /* */ * from sashelp.class;
  select a.*, b.* from a,b;

/* 10. in a macro but wrapped in brackets */
%macro x;(*)%mend;%x;

Link to docs: https://documentation.sas.com/doc/en/pgmsascdc/v_015/lestmtsglobal/n1v51exifva71an1cvfn2z6j26lo.htm?homeOnFail

@Carus11
Copy link
Author

Carus11 commented Jul 22, 2021

Oh wow thanks Allan,
I'll have some of our devs have a look at your cases. I just realized now my example was wrong because I didnt terminate the comment with a semicolon. I am going to leave it that way as that is the very mistake I find sneaks into our code base time and time again when we comment using the single asterisk method.

@allanbowe
Copy link
Member

I'm wondering if we will need to build a tokenizer to make this work!

@allanbowe
Copy link
Member

@all-contributors add @Carus11 for ideas

@allcontributors
Copy link
Contributor

@allanbowe

I've put up a pull request to add @Carus11! 🎉

@krishna-acondy
Copy link
Contributor

Hello @Carus11 @allanbowe Thanks for the idea and your input. 🙌🏽
I'll take an initial crack at implementing this at some point next week.

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

No branches or pull requests

3 participants