xref: /curl/tests/data/test1185 (revision b7c9166c)
1<testcase>
2<info>
3<keywords>
4checksrc
5</keywords>
6</info>
7
8#
9# Client-side
10<client>
11<server>
12none
13</server>
14<name>
15checksrc
16</name>
17
18<command type="perl">
19%SRCDIR/../scripts/checksrc.pl %LOGDIR/code%TESTNUMBER.c
20</command>
21<file name="%LOGDIR/code%TESTNUMBER.c">
22/* test source code
23 * Violate each rule at least once.
24 **/
25int hello; /*------------------------------------------------------------------*/
26int	tab;
27int trailing_space;
28int a = func ();
29int b = func( b);
30int b = func(b );
31func(a, b , c);
32
33int hello()
34{
35  return(2);
36}
37func(a, b,c);
38
39if(a == 2) {
40  ;
41} else {
42  moo = 2;
43}
44
45if(a == 2){ /* followed by comment */
46  ;
47}
48
49func() ;
50
51a = sprintf(buffer, "%s", moo);
52
53FILE *f = fopen("filename", "r");
54
55void startfunc(int a, int b) {
56  func();
57}
58
59 for(;;) {
60     func(1);
61 } while(1);
62
63 char * name = "hello";
64 char* name = "hello";
65
66 int foo=bar;
67 int foo= bar;
68 int foo = bar;
69 int foo = bar;foo++;
70 for(;;)  {
71 }
72
73 int a = sizeof int;
74 int a = snprintf(buffer, sizeof(buffer), "%d", 99);
75 int moo = hej?wrong:a>b;
76 int moo2 = wrong2:(a)>(b);
77
78 if(a) b++;
79
80 // CPP comment ?
81
82 /* comment doesn't end
83
84</file>
85</client>
86
87#
88# Verify data after the test has been "shot"
89<verify>
90<stdout>
91./%LOGDIR/code1185.c:4:82: warning: Longer than 79 columns (LONGLINE)
92 int hello; /*------------------------------------------------------------------*/
93./%LOGDIR/code1185.c:5:4: error: Contains TAB character (TABS)
94 int	tab;
95    ^
96./%LOGDIR/code1185.c:7:13: warning:  func with space (SPACEBEFOREPAREN)
97 int a = func ();
98             ^
99./%LOGDIR/code1185.c:8:14: warning: space after open parenthesis (SPACEAFTERPAREN)
100 int b = func( b);
101              ^
102./%LOGDIR/code1185.c:9:16: warning: space before close parenthesis (SPACEBEFORECLOSE)
103 int b = func(b );
104                ^
105./%LOGDIR/code1185.c:10:11: warning: space before comma (SPACEBEFORECOMMA)
106 func(a, b , c);
107           ^
108./%LOGDIR/code1185.c:14:9: warning: return without space before paren (RETURNNOSPACE)
109   return(2);
110         ^
111./%LOGDIR/code1185.c:16:11: warning: comma without following space (COMMANOSPACE)
112 func(a, b,c);
113           ^
114./%LOGDIR/code1185.c:18:12: warning: wrongly placed open brace (BRACEPOS)
115 if(a == 2) {
116            ^
117./%LOGDIR/code1185.c:20:1: warning: else after closing brace on same line (BRACEELSE)
118 } else {
119 ^
120./%LOGDIR/code1185.c:24:11: warning: missing space after close paren (PARENBRACE)
121 if(a == 2){
122           ^
123./%LOGDIR/code1185.c:28:7: warning: no space before semicolon (SPACESEMICOLON)
124 func() ;
125       ^
126./%LOGDIR/code1185.c:30:5: warning: use of sprintf is banned (BANNEDFUNC)
127 a = sprintf(buffer, "%s", moo);
128     ^
129./%LOGDIR/code1185.c:32:11: warning: use of non-binary fopen without FOPEN_* macro: r (FOPENMODE)
130 FILE *f = fopen("filename", "r");
131           ^
132./%LOGDIR/code1185.c:34:30: warning: wrongly placed open brace (BRACEPOS)
133 void startfunc(int a, int b) {
134                              ^
135./%LOGDIR/code1185.c:39:6: warning: not indented 2 steps (uses 4) (INDENTATION)
136      func(1);
137      ^
138./%LOGDIR/code1185.c:42:8: warning: space after declarative asterisk (ASTERISKSPACE)
139  char * name = "hello";
140        ^
141./%LOGDIR/code1185.c:43:7: warning: space after declarative asterisk (ASTERISKSPACE)
142  char* name = "hello";
143       ^
144./%LOGDIR/code1185.c:43:6: warning: no space before asterisk (ASTERISKNOSPACE)
145  char* name = "hello";
146      ^
147./%LOGDIR/code1185.c:45:10: warning: no space after equals sign (EQUALSNOSPACE)
148  int foo=bar;
149          ^
150./%LOGDIR/code1185.c:46:9: warning: no space before equals sign (NOSPACEEQUALS)
151  int foo= bar;
152         ^
153./%LOGDIR/code1185.c:48:16: warning: no space after semicolon (SEMINOSPACE)
154  int foo = bar;foo++;
155                ^
156./%LOGDIR/code1185.c:49:10: warning: multiple spaces (MULTISPACE)
157  for(;;)  {
158          ^
159./%LOGDIR/code1185.c:50:2: warning: not indented 2 steps (uses 0) (INDENTATION)
160  }
161  ^
162./%LOGDIR/code1185.c:52:16: warning: sizeof without parenthesis (SIZEOFNOPAREN)
163  int a = sizeof int;
164                ^
165./%LOGDIR/code1185.c:53:10: warning: use of snprintf is banned (SNPRINTF)
166  int a = snprintf(buffer, sizeof(buffer), "%d", 99);
167          ^
168./%LOGDIR/code1185.c:54:21: warning: missing space before colon (NOSPACEC)
169  int moo = hej?wrong:a>b;
170                     ^
171./%LOGDIR/code1185.c:54:22: warning: missing space after colon (NOSPACEC)
172  int moo = hej?wrong:a>b;
173                      ^
174./%LOGDIR/code1185.c:54:15: warning: missing space before question mark (NOSPACEQ)
175  int moo = hej?wrong:a>b;
176               ^
177./%LOGDIR/code1185.c:54:16: warning: missing space after question mark (NOSPACEQ)
178  int moo = hej?wrong:a>b;
179                ^
180./%LOGDIR/code1185.c:54:23: warning: missing space before less or greater than (NOSPACETHAN)
181  int moo = hej?wrong:a>b;
182                       ^
183./%LOGDIR/code1185.c:54:23: warning: missing space after less or greater than (NOSPACETHAN)
184  int moo = hej?wrong:a>b;
185                       ^
186./%LOGDIR/code1185.c:55:23: warning: missing space before less or greater than (NOSPACETHAN)
187  int moo2 = wrong2:(a)>(b);
188                       ^
189./%LOGDIR/code1185.c:55:23: warning: missing space after less or greater than (NOSPACETHAN)
190  int moo2 = wrong2:(a)>(b);
191                       ^
192./%LOGDIR/code1185.c:57:7: warning: conditional block on the same line (ONELINECONDITION)
193  if(a) b++;
194       ^
195./%LOGDIR/code1185.c:59:2: warning: // comment (CPPCOMMENTS)
196  // CPP comment ?
197  ^
198./%LOGDIR/code1185.c:1:1: error: Missing copyright statement (COPYRIGHT)
199
200 ^
201./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT)
202
203 ^
204checksrc: 0 errors and 38 warnings
205</stdout>
206<errorcode>
2075
208</errorcode>
209</verify>
210</testcase>
211