Merge branch 'tkruse-upgrade-checkers'

This commit is contained in:
Andrew Pardoe 2016-08-22 11:09:17 -07:00
commit 60330bdede
7 changed files with 810 additions and 766 deletions

View File

@ -3337,7 +3337,8 @@ There is not a choice when a set of functions are used to do a semantically equi
##### See also
[Default arguments for virtual functions](#Rh-virtual-default-arg)
[Default arguments for virtual functions](#Rf-virtual-default-arg}
##### Enforcement

View File

@ -21,7 +21,7 @@ cpplint-all \
check-badchars
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)
#### clean: remove all files generated by the productive rules
.PHONY: clean
@ -36,16 +36,16 @@ distclean:
#### check markdown
## run remark markdown checker based on configuration in .remarkrc
## run remark markdown checker based on configuration in package.json
.PHONY: check-markdown
check-markdown: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BUILD_DIR) Makefile
check-markdown: nodejs/node_modules/remark nodejs/package.json $(SOURCEPATH) $(BUILD_DIR) Makefile
## run remark, paste output to temporary file
cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q --config-path ./remark/.remarkrc 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed --frail
cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed --frail
## show a diff with changes remark suggests
.PHONY: show-diff
show-diff: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BUILD_DIR) Makefile
cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q --config-path ./remark/.remarkrc 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed
show-diff: nodejs/node_modules/remark nodejs/package.json $(SOURCEPATH) $(BUILD_DIR) Makefile
cd nodejs; ./node_modules/.bin/remark ../$(SOURCEPATH) --no-color -q 1> ../$(BUILD_DIR)/$(SOURCEFILE).fixed
## compare temporary file to original, error and fail with message if differences exist
diff $(SOURCEPATH) $(BUILD_DIR)/$(SOURCEFILE).fixed -u3 || \
(echo "Error: remark found bad markdown syntax, see output above" && false)
@ -54,28 +54,28 @@ show-diff: nodejs/node_modules/remark nodejs/remark/.remarkrc $(SOURCEPATH) $(BU
.PHONY: check-references
check-references: $(SOURCEPATH) $(BUILD_DIR) Makefile
## check references unique
rm -f $(BUILD_DIR)/$(SOURCEFILE).uniq
grep -oP '(?<=<a name=")[^\"]+' $(SOURCEPATH) | uniq -d > $(BUILD_DIR)/$(SOURCEFILE).uniq
@rm -f $(BUILD_DIR)/$(SOURCEFILE).uniq
@grep -oP '(?<=<a name=")[^\"]+' $(SOURCEPATH) | uniq -d > $(BUILD_DIR)/$(SOURCEFILE).uniq
## check if output has data
if [ -s "build/CppCoreGuidelines.md.uniq" ]; then echo 'Found duplicate anchors:'; cat $(BUILD_DIR)/$(SOURCEFILE).uniq; false; fi
@if [ -s "build/CppCoreGuidelines.md.uniq" ]; then echo 'Found duplicate anchors:'; cat $(BUILD_DIR)/$(SOURCEFILE).uniq; false; fi
.PHONY: check-notabs
check-notabs: $(SOURCEPATH) $(BUILD_DIR) Makefile
# find lines with tabs
# old file still might be around
rm -f $(BUILD_DIR)/CppCoreGuidelines.md.tabs
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.tabs
# print file, add line numbers, remove tabs from nl tool, grep for remaining tabs, replace with stars
cat ../CppCoreGuidelines.md | nl -ba | sed -s 's/\(^[^\t]*\)\t/\1--/g' | grep -P '\t' | sed -s 's/\t/\*\*\*\*/g' > $(BUILD_DIR)/CppCoreGuidelines.md.tabs
if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.tabs ]; then echo 'Warning: Tabs found:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.tabs; false; fi;
@cat ../CppCoreGuidelines.md | nl -ba | sed -s 's/\(^[^\t]*\)\t/\1--/g' | grep -P '\t' | sed -s 's/\t/\*\*\*\*/g' > $(BUILD_DIR)/CppCoreGuidelines.md.tabs
@if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.tabs ]; then echo 'Warning: Tabs found:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.tabs; false; fi;
.PHONY: check-badchars
check-badchars: $(SOURCEPATH) $(BUILD_DIR) Makefile
# find lines with tabs
# old file still might be around
rm -f $(BUILD_DIR)/CppCoreGuidelines.md.badchars
@rm -f $(BUILD_DIR)/CppCoreGuidelines.md.badchars
# print file, add line numbers, grep for bad chars
cat ../CppCoreGuidelines.md | nl -ba | grep -P '||”|“|¸||…|¦' > $(BUILD_DIR)/CppCoreGuidelines.md.badchars || true
if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.badchars ]; then echo 'Warning: Undesired chars (–’‘“”¸…¦) found, use straight quotes instead:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.badchars; false; fi;
@cat ../CppCoreGuidelines.md | nl -ba | grep -P '||”|“|¸||…|¦' > $(BUILD_DIR)/CppCoreGuidelines.md.badchars || true
@if [ -s $(BUILD_DIR)/CppCoreGuidelines.md.badchars ]; then echo 'Warning: Undesired chars (–’‘“”¸…¦) found, use straight quotes instead:'; cat $(BUILD_DIR)/CppCoreGuidelines.md.badchars; false; fi;
@ -88,7 +88,7 @@ cpplint-all: $(BUILD_DIR)/codeblocks $(BUILD_DIR)/Makefile python/Makefile.in
#### generic makefile for sourceblocks (need to be evaluated after c++ file generation)
$(BUILD_DIR)/Makefile: python/Makefile.in
cp python/Makefile.in $(BUILD_DIR)/codeblocks/Makefile
@cp python/Makefile.in $(BUILD_DIR)/codeblocks/Makefile
#### split md file into plain text and code
@ -98,7 +98,7 @@ $(BUILD_DIR)/plain.txt: splitfile
.PHONY: splitfile
splitfile: $(SOURCEPATH) ./python/md-split.py
python ./python/md-split.py $(SOURCEPATH) $(BUILD_DIR)/plain.txt $(BUILD_DIR)/codeblocks
@python ./python/md-split.py $(SOURCEPATH) $(BUILD_DIR)/plain.txt $(BUILD_DIR)/codeblocks
#### install npm modules
# install/update npm dependencies defined in file package.json

View File

@ -1,12 +1,44 @@
{
"name": "CppCoreGuidelinesCheck",
"version": "0.0.0",
"description": "CppCoreGuidelines Check",
"private": true,
"dependencies": {
"remark": "^4.2.0",
"remark-lint": "^3.2.0",
"remark-lint-sentence-newline": "^2.0.0",
"remark-validate-links": "^3.0.0"
}
"name": "CppCoreGuidelinesCheck",
"version": "0.0.0",
"description": "CppCoreGuidelines Check",
"private": true,
"dependencies": {
"remark": "^4.2.2",
"remark-lint": "^4.0.2",
"remark-lint-sentence-newline": "^2.0.0",
"remark-validate-links": "^4.1.0",
"remark-lint-are-links-valid": "^1.0.2"
},
"remarkConfig": {
"plugins": {
"remark-lint": {
"unordered-list-marker-style": "consistent",
"list-item-bullet-indent": false,
"list-item-indent": false,
"list-item-spacing": false,
"no-html": false,
"maximum-line-length": false,
"no-file-name-mixed-case": false,
"heading-increment": false,
"no-multiple-toplevel-headings": false,
"no-consecutive-blank-lines": false,
"maximum-line-length": 9000,
"maximum-heading-length": 300,
"no-heading-punctuation": false,
"no-duplicate-headings": false,
"emphasis-marker": "*",
"no-tabs": false,
"blockquote-indentation": false,
"strong-marker": "*",
"external": ["remark-lint-are-links-valid"]
}
},
"settings": {
"bullet": "*",
"listItemIndent": "1",
"strong": "*",
"emphasis": "*"
}
}
}

View File

@ -1,31 +0,0 @@
{
"plugins": {
"remark-lint": {
"unordered-list-marker-style": "consistent",
"list-item-bullet-indent": false,
"list-item-indent": false,
"list-item-spacing": false,
"no-html": false,
"maximum-line-length": false,
"no-file-name-mixed-case": false,
"heading-increment": false,
"no-multiple-toplevel-headings": false,
"no-consecutive-blank-lines": false,
"maximum-line-length": 9000,
"maximum-heading-length": 300,
"no-heading-punctuation": false,
"no-duplicate-headings": false,
"emphasis-marker": "*",
"no-tabs": false,
"blockquote-indentation": false,
"strong-marker": "*"
}
},
"settings": {
"bullet": "*",
"listItemIndent": "1",
"strong": "*",
"emphasis": "*"
}
}

View File

@ -14,5 +14,5 @@ CXX_LINT := ${CXX_SRCS:.cpp=.lint}
cpplint-all: $(CXX_LINT)
%.lint: %.cpp
@python ../../python/cpplint.py --verbose=0 --linelength=100 --filter=-legal/copyright,-build/include_order,-build/c++11,-build/namespaces,-readability/inheritance,-readability/function,-readability/casting,-readability/namespace,-readability/alt_tokens,-readability/braces,-readability/fn_size,-whitespace/comments,-whitespace/braces,-whitespace/empty_loop_body,-whitespace/indent,-whitespace/newline,-runtime/explicit,-runtime/arrays,-runtime/int,-runtime/references,-runtime/string,-runtime/operator $< || (cat $< | nl -ba | grep -v 'md-split' && false)
@python ../../python/cpplint.py --verbose=0 --linelength=100 --filter=-legal/copyright,-build/include_order,-build/c++11,-build/namespaces,-build/class,-build/include,-build/include_subdir,-readability/inheritance,-readability/function,-readability/casting,-readability/namespace,-readability/alt_tokens,-readability/braces,-readability/fn_size,-whitespace/comments,-whitespace/braces,-whitespace/empty_loop_body,-whitespace/indent,-whitespace/newline,-runtime/explicit,-runtime/arrays,-runtime/int,-runtime/references,-runtime/string,-runtime/operator $< || (cat $< | nl -ba | grep -v 'md-split' && false)

File diff suppressed because it is too large Load Diff

View File

@ -74,7 +74,6 @@ def main():
def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, codedir, name, index, indent_depth):
fenced = (line.strip() == '```')
if fenced:
try:
@ -94,18 +93,18 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
if comment_idx >= 0:
no_comment_line = line[:comment_idx]
text_filehandle.write(line[comment_idx + 2:])
if (not has_actual_code
and not line.strip().startswith('//')
and not line.strip().startswith('???')
and not line.strip() ==''):
has_actual_code = True
if (not has_actual_code
and not line.strip().startswith('//')
and not line.strip().startswith('???')
and not line.strip() ==''):
has_actual_code = True
else:
# write empty line so line numbers stay stable
text_filehandle.write('')
if (not line.strip() == '```'):
if ('???' in no_comment_line or '...' in no_comment_line):
if ('???' == no_comment_line or '...' == no_comment_line):
has_question_marks = True
linebuffer.append(dedent(line) if not fenced else line)
try:
@ -115,10 +114,8 @@ def process_code(read_filehandle, text_filehandle, line, linenum, sourcefile, co
line = ''
break
codefile = os.path.join(codedir, '%s%s.cpp' % (name, index))
if fenced:
text_filehandle.write('')
if (has_actual_code and not has_question_marks):
# add commonly used headers, so that lines can compile
with io.open(codefile, 'w') as code_filehandle:
@ -145,6 +142,7 @@ using namespace std; // by md-split
def is_code(line, indent_depth = 4):
'''returns the indent depth, 0 means not code in markup'''
if line.startswith(' ' * indent_depth):
return len(line) - len(line.lstrip(' '))
return 0
@ -171,6 +169,7 @@ def get_marker(line):
namematch = NAMED_A_TAG_REGEX.match(line)
if namematch:
return namematch.group(1) # group 0 is full match
return None
if __name__ == '__main__':