Skip to content

Commit 31c03ed

Browse files
committed
some changes for documentation, more to come
1 parent 6936637 commit 31c03ed

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

TODO

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Rule 8 1 A : add indentification of which info is missing
2+
Rule 3 1 A : ensure no main.h
3+
4+
Comments after closing of a block more than 15 lines
5+
6+
unittest everything

rules/RULE_8_1_A_provide_file_info_comment.py

+33-20
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,67 @@
1010
#define "AA" <== Violation. file comment should be the first element of file.
1111
///
1212
/// blar blar
13-
/// Copyright reserved.
13+
/// Copyright reserved.
1414
///
15-
16-
= start of file =
15+
16+
= start of file =
1717
/** <== Violation. No copyright string.
18-
* blar blar
18+
* blar blar
1919
* blar blar
2020
*/
21-
21+
2222
== Good ==
2323
24-
= start of file =
24+
= start of file =
2525
///
2626
/// blar blar
2727
/// Copyright reserved. <== Correct
28+
/// file
29+
/// author
30+
/// date
31+
/// version
32+
/// brief
2833
///
29-
30-
= start of file =
34+
35+
= start of file =
3136
/**
3237
* blar blar
3338
* Copyright reserved. <== Correct
39+
* file
40+
* author
41+
* date
42+
* version
43+
* brief
3444
* blar blar
3545
*/
3646
"""
37-
from nsiqcppstyle_rulehelper import *
47+
from nsiqcppstyle_rulehelper import *
3848
from nsiqcppstyle_reporter import *
3949
from nsiqcppstyle_rulemanager import *
4050

51+
def error(lexer):
52+
nsiqcppstyle_reporter.Error(DummyToken(lexer.filename, "", 1, 0),
53+
__name__, """Please provide file info comment in front of
54+
file. It includes license/copyright information along
55+
with filename, author, date of modification, version and
56+
a brief description""")
57+
4158
def RunRule(lexer, filename, dirname) :
4259

4360
t = lexer.GetNextTokenSkipWhiteSpace()
4461
if t == None : return
45-
if t.type == "COMMENT" :
46-
if t.value.lower().find("copyright") == -1 :
47-
nsiqcppstyle_reporter.Error(DummyToken(lexer.filename, "", 1, 0), __name__, "Please provide file info comment in front of file")
48-
49-
elif t.type == "CPPCOMMENT" :
62+
if t.type in ("COMMENT", "CPPCOMMENT") :
5063
find = False
5164
while(t != None and t.type == "CPPCOMMENT") :
52-
if t.value.lower().find("copyright") != -1 :
65+
if t.value.lower().find("copyright") != -1 or t.value.lower().find("license") != -1:
5366
find = True
5467
break;
5568
t = lexer.GetNextTokenSkipWhiteSpace()
5669
if not find :
57-
nsiqcppstyle_reporter.Error(DummyToken(lexer.filename, "", 1, 0), __name__, "Please provide file info comment in front of file")
70+
error(lexer)
5871
else :
59-
nsiqcppstyle_reporter.Error(DummyToken(lexer.filename, "", 1, 0), __name__, "Please provide file info comment in front of file")
60-
72+
error(lexer)
73+
6174
ruleManager.AddFileStartRule(RunRule)
6275

6376
###########################################################################################
@@ -67,7 +80,7 @@ def RunRule(lexer, filename, dirname) :
6780
from nsiqunittest.nsiqcppstyle_unittestbase import *
6881
class testRule(nct):
6982
def setUpRule(self):
70-
ruleManager.AddFileStartRule(RunRule)
83+
ruleManager.AddFileStartRule(RunRule)
7184
def test1(self):
7285
self.Analyze("thisfile.c","""
7386
// license
@@ -110,4 +123,4 @@ def test6(self):
110123
#define "WEWE"
111124
#include </ewe/kk> """)
112125
assert not CheckErrorContent(__name__)
113-
126+

0 commit comments

Comments
 (0)