Commit dcac97b8 authored by Sergio Martins's avatar Sergio Martins
Browse files

Make it easier to link to READMEs by removing the level name.

After make install they will still be installed to a level0, 1, 2 sub-folder,
as the cmake instructions are generated by generate.py

BUG: 394237
parent fa6f5d8e
......@@ -193,11 +193,9 @@ if (NOT CLAZY_BUILD_WITH_CLANG)
# Install the explanation README's
set(DOC_INSTALL_DIR ${SHARE_INSTALL_DIR}/clazy/doc)
file(GLOB README_LEVEL0_FILES src/checks/level0/README-*)
file(GLOB README_LEVEL1_FILES src/checks/level1/README-*)
file(GLOB README_LEVEL2_FILES src/checks/level2/README-*)
file(GLOB README_LEVEL3_FILES src/checks/level3/README-*)
file(GLOB README_manuallevel_FILES src/checks/manuallevel/README-*)
include(${CMAKE_CURRENT_LIST_DIR}/readmes.cmake)
install(FILES ${README_LEVEL0_FILES} DESTINATION ${DOC_INSTALL_DIR}/level0)
install(FILES ${README_LEVEL1_FILES} DESTINATION ${DOC_INSTALL_DIR}/level1)
install(FILES ${README_LEVEL2_FILES} DESTINATION ${DOC_INSTALL_DIR}/level2)
......
......@@ -216,89 +216,89 @@ There are many checks and they are divided in levels:
clazy runs all checks from level1 by default.
- Checks from Manual Level:
- [container-inside-loop](src/checks/manuallevel/README-container-inside-loop.md)
- [inefficient-qlist](src/checks/manuallevel/README-inefficient-qlist.md)
- [isempty-vs-count](src/checks/manuallevel/README-isempty-vs-count.md)
- [qhash-with-char-pointer-key](src/checks/manuallevel/README-qhash-with-char-pointer-key.md)
- [qstring-varargs](src/checks/manuallevel/README-qstring-varargs.md)
- [qt-keywords](src/checks/manuallevel/README-qt-keywords.md) (fix-qt-keywords)
- [qt4-qstring-from-array](src/checks/manuallevel/README-qt4-qstring-from-array.md) (fix-qt4-qstring-from-array)
- [tr-non-literal](src/checks/manuallevel/README-tr-non-literal.md)
- [unneeded-cast](src/checks/manuallevel/README-unneeded-cast.md)
- [container-inside-loop](docs/checks/README-container-inside-loop.md)
- [inefficient-qlist](docs/checks/README-inefficient-qlist.md)
- [isempty-vs-count](docs/checks/README-isempty-vs-count.md)
- [qhash-with-char-pointer-key](docs/checks/README-qhash-with-char-pointer-key.md)
- [qstring-varargs](docs/checks/README-qstring-varargs.md)
- [qt-keywords](docs/checks/README-qt-keywords.md) (fix-qt-keywords)
- [qt4-qstring-from-array](docs/checks/README-qt4-qstring-from-array.md) (fix-qt4-qstring-from-array)
- [tr-non-literal](docs/checks/README-tr-non-literal.md)
- [unneeded-cast](docs/checks/README-unneeded-cast.md)
- Checks from Level 0:
- [connect-by-name](src/checks/level0/README-connect-by-name.md)
- [connect-non-signal](src/checks/level0/README-connect-non-signal.md)
- [connect-not-normalized](src/checks/level0/README-connect-not-normalized.md)
- [container-anti-pattern](src/checks/level0/README-container-anti-pattern.md)
- [fully-qualified-moc-types](src/checks/level0/README-fully-qualified-moc-types.md)
- [lambda-in-connect](src/checks/level0/README-lambda-in-connect.md)
- [lambda-unique-connection](src/checks/level0/README-lambda-unique-connection.md)
- [mutable-container-key](src/checks/level0/README-mutable-container-key.md)
- [qcolor-from-literal](src/checks/level0/README-qcolor-from-literal.md)
- [qdatetime-utc](src/checks/level0/README-qdatetime-utc.md) (fix-qdatetime-utc)
- [qenums](src/checks/level0/README-qenums.md)
- [qfileinfo-exists](src/checks/level0/README-qfileinfo-exists.md)
- [qgetenv](src/checks/level0/README-qgetenv.md) (fix-qgetenv)
- [qmap-with-pointer-key](src/checks/level0/README-qmap-with-pointer-key.md)
- [qstring-arg](src/checks/level0/README-qstring-arg.md)
- [qstring-insensitive-allocation](src/checks/level0/README-qstring-insensitive-allocation.md)
- [qstring-ref](src/checks/level0/README-qstring-ref.md) (fix-missing-qstringref)
- [qt-macros](src/checks/level0/README-qt-macros.md)
- [qvariant-template-instantiation](src/checks/level0/README-qvariant-template-instantiation.md)
- [strict-iterators](src/checks/level0/README-strict-iterators.md)
- [temporary-iterator](src/checks/level0/README-temporary-iterator.md)
- [unused-non-trivial-variable](src/checks/level0/README-unused-non-trivial-variable.md)
- [writing-to-temporary](src/checks/level0/README-writing-to-temporary.md)
- [wrong-qevent-cast](src/checks/level0/README-wrong-qevent-cast.md)
- [wrong-qglobalstatic](src/checks/level0/README-wrong-qglobalstatic.md)
- [connect-by-name](docs/checks/README-connect-by-name.md)
- [connect-non-signal](docs/checks/README-connect-non-signal.md)
- [connect-not-normalized](docs/checks/README-connect-not-normalized.md)
- [container-anti-pattern](docs/checks/README-container-anti-pattern.md)
- [fully-qualified-moc-types](docs/checks/README-fully-qualified-moc-types.md)
- [lambda-in-connect](docs/checks/README-lambda-in-connect.md)
- [lambda-unique-connection](docs/checks/README-lambda-unique-connection.md)
- [mutable-container-key](docs/checks/README-mutable-container-key.md)
- [qcolor-from-literal](docs/checks/README-qcolor-from-literal.md)
- [qdatetime-utc](docs/checks/README-qdatetime-utc.md) (fix-qdatetime-utc)
- [qenums](docs/checks/README-qenums.md)
- [qfileinfo-exists](docs/checks/README-qfileinfo-exists.md)
- [qgetenv](docs/checks/README-qgetenv.md) (fix-qgetenv)
- [qmap-with-pointer-key](docs/checks/README-qmap-with-pointer-key.md)
- [qstring-arg](docs/checks/README-qstring-arg.md)
- [qstring-insensitive-allocation](docs/checks/README-qstring-insensitive-allocation.md)
- [qstring-ref](docs/checks/README-qstring-ref.md) (fix-missing-qstringref)
- [qt-macros](docs/checks/README-qt-macros.md)
- [qvariant-template-instantiation](docs/checks/README-qvariant-template-instantiation.md)
- [strict-iterators](docs/checks/README-strict-iterators.md)
- [temporary-iterator](docs/checks/README-temporary-iterator.md)
- [unused-non-trivial-variable](docs/checks/README-unused-non-trivial-variable.md)
- [writing-to-temporary](docs/checks/README-writing-to-temporary.md)
- [wrong-qevent-cast](docs/checks/README-wrong-qevent-cast.md)
- [wrong-qglobalstatic](docs/checks/README-wrong-qglobalstatic.md)
- Checks from Level 1:
- [auto-unexpected-qstringbuilder](src/checks/level1/README-auto-unexpected-qstringbuilder.md) (fix-auto-unexpected-qstringbuilder)
- [child-event-qobject-cast](src/checks/level1/README-child-event-qobject-cast.md)
- [connect-3arg-lambda](src/checks/level1/README-connect-3arg-lambda.md)
- [const-signal-or-slot](src/checks/level1/README-const-signal-or-slot.md)
- [detaching-temporary](src/checks/level1/README-detaching-temporary.md)
- [foreach](src/checks/level1/README-foreach.md)
- [incorrect-emit](src/checks/level1/README-incorrect-emit.md)
- [inefficient-qlist-soft](src/checks/level1/README-inefficient-qlist-soft.md)
- [install-event-filter](src/checks/level1/README-install-event-filter.md)
- [non-pod-global-static](src/checks/level1/README-non-pod-global-static.md)
- [overridden-signal](src/checks/level1/README-overridden-signal.md)
- [post-event](src/checks/level1/README-post-event.md)
- [qdeleteall](src/checks/level1/README-qdeleteall.md)
- [qhash-namespace](src/checks/level1/README-qhash-namespace.md)
- [qlatin1string-non-ascii](src/checks/level1/README-qlatin1string-non-ascii.md)
- [qproperty-without-notify](src/checks/level1/README-qproperty-without-notify.md)
- [qstring-left](src/checks/level1/README-qstring-left.md)
- [range-loop](src/checks/level1/README-range-loop.md)
- [returning-data-from-temporary](src/checks/level1/README-returning-data-from-temporary.md)
- [rule-of-two-soft](src/checks/level1/README-rule-of-two-soft.md)
- [skipped-base-method](src/checks/level1/README-skipped-base-method.md)
- [virtual-signal](src/checks/level1/README-virtual-signal.md)
- [auto-unexpected-qstringbuilder](docs/checks/README-auto-unexpected-qstringbuilder.md) (fix-auto-unexpected-qstringbuilder)
- [child-event-qobject-cast](docs/checks/README-child-event-qobject-cast.md)
- [connect-3arg-lambda](docs/checks/README-connect-3arg-lambda.md)
- [const-signal-or-slot](docs/checks/README-const-signal-or-slot.md)
- [detaching-temporary](docs/checks/README-detaching-temporary.md)
- [foreach](docs/checks/README-foreach.md)
- [incorrect-emit](docs/checks/README-incorrect-emit.md)
- [inefficient-qlist-soft](docs/checks/README-inefficient-qlist-soft.md)
- [install-event-filter](docs/checks/README-install-event-filter.md)
- [non-pod-global-static](docs/checks/README-non-pod-global-static.md)
- [overridden-signal](docs/checks/README-overridden-signal.md)
- [post-event](docs/checks/README-post-event.md)
- [qdeleteall](docs/checks/README-qdeleteall.md)
- [qhash-namespace](docs/checks/README-qhash-namespace.md)
- [qlatin1string-non-ascii](docs/checks/README-qlatin1string-non-ascii.md)
- [qproperty-without-notify](docs/checks/README-qproperty-without-notify.md)
- [qstring-left](docs/checks/README-qstring-left.md)
- [range-loop](docs/checks/README-range-loop.md)
- [returning-data-from-temporary](docs/checks/README-returning-data-from-temporary.md)
- [rule-of-two-soft](docs/checks/README-rule-of-two-soft.md)
- [skipped-base-method](docs/checks/README-skipped-base-method.md)
- [virtual-signal](docs/checks/README-virtual-signal.md)
- Checks from Level 2:
- [base-class-event](src/checks/level2/README-base-class-event.md)
- [copyable-polymorphic](src/checks/level2/README-copyable-polymorphic.md)
- [ctor-missing-parent-argument](src/checks/level2/README-ctor-missing-parent-argument.md)
- [function-args-by-ref](src/checks/level2/README-function-args-by-ref.md)
- [function-args-by-value](src/checks/level2/README-function-args-by-value.md)
- [global-const-char-pointer](src/checks/level2/README-global-const-char-pointer.md)
- [implicit-casts](src/checks/level2/README-implicit-casts.md)
- [missing-qobject-macro](src/checks/level2/README-missing-qobject-macro.md)
- [missing-typeinfo](src/checks/level2/README-missing-typeinfo.md)
- [old-style-connect](src/checks/level2/README-old-style-connect.md) (fix-old-style-connect)
- [qstring-allocations](src/checks/level2/README-qstring-allocations.md) (fix-qlatin1string-allocations,fix-fromLatin1_fromUtf8-allocations,fix-fromCharPtrAllocations)
- [returning-void-expression](src/checks/level2/README-returning-void-expression.md)
- [rule-of-three](src/checks/level2/README-rule-of-three.md)
- [static-pmf](src/checks/level2/README-static-pmf.md)
- [virtual-call-ctor](src/checks/level2/README-virtual-call-ctor.md)
- [base-class-event](docs/checks/README-base-class-event.md)
- [copyable-polymorphic](docs/checks/README-copyable-polymorphic.md)
- [ctor-missing-parent-argument](docs/checks/README-ctor-missing-parent-argument.md)
- [function-args-by-ref](docs/checks/README-function-args-by-ref.md)
- [function-args-by-value](docs/checks/README-function-args-by-value.md)
- [global-const-char-pointer](docs/checks/README-global-const-char-pointer.md)
- [implicit-casts](docs/checks/README-implicit-casts.md)
- [missing-qobject-macro](docs/checks/README-missing-qobject-macro.md)
- [missing-typeinfo](docs/checks/README-missing-typeinfo.md)
- [old-style-connect](docs/checks/README-old-style-connect.md) (fix-old-style-connect)
- [qstring-allocations](docs/checks/README-qstring-allocations.md) (fix-qlatin1string-allocations,fix-fromLatin1_fromUtf8-allocations,fix-fromCharPtrAllocations)
- [returning-void-expression](docs/checks/README-returning-void-expression.md)
- [rule-of-three](docs/checks/README-rule-of-three.md)
- [static-pmf](docs/checks/README-static-pmf.md)
- [virtual-call-ctor](docs/checks/README-virtual-call-ctor.md)
- Checks from Level 3:
- [assert-with-side-effects](src/checks/level3/README-assert-with-side-effects.md)
- [detaching-member](src/checks/level3/README-detaching-member.md)
- [reserve-candidates](src/checks/level3/README-reserve-candidates.md)
- [thread-with-slots](src/checks/level3/README-thread-with-slots.md)
- [assert-with-side-effects](docs/checks/README-assert-with-side-effects.md)
- [detaching-member](docs/checks/README-detaching-member.md)
- [reserve-candidates](docs/checks/README-reserve-candidates.md)
- [thread-with-slots](docs/checks/README-thread-with-slots.md)
# Selecting which checks to enable
......
......@@ -51,12 +51,26 @@ def level_num_to_name(n):
return 'undefined'
def level_num_to_cmake_readme_variable(n):
if n == -1:
return 'README_manuallevel_FILES'
if n >= 0 and n <= 3:
return 'README_LEVEL%s_FILES' % str(n)
return 'undefined'
def clazy_source_path():
return os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/..") + "/"
def templates_path():
return clazy_source_path() + "dev-scripts/templates/"
def docs_relative_path():
return "docs/checks/"
def docs_path():
return clazy_source_path() + docs_relative_path()
def read_file(filename):
f = io.open(filename, 'r', newline='\n', encoding='utf8')
contents = f.read()
......@@ -120,7 +134,7 @@ class Check:
return "README-" + self.name + ".md"
def readme_path(self):
return clazy_source_path() + self.basedir(True) + self.readme_name()
return docs_path() + self.readme_name()
def supportsQt4(self):
......@@ -337,7 +351,6 @@ def create_readmes(checks):
os.remove(existing_readme)
print("Moved " + check.readme_name())
else:
contents = read_file(templates_path() + "check-readme.md")
contents = contents.replace('[check-name]', check.name)
write_file(check.readme_path(), contents)
......@@ -432,7 +445,6 @@ def create_checks(checks):
return generated
#-------------------------------------------------------------------------------
def generate_readme(checks):
filename = clazy_source_path() + "README.md"
f = io.open(filename, 'r', newline='\n', encoding='utf8')
old_contents = f.readlines();
......@@ -446,7 +458,7 @@ def generate_readme(checks):
fixits_text = c.fixits_text()
if fixits_text:
fixits_text = " " + fixits_text
new_text_to_insert += " - [%s](%sREADME-%s.md)%s" % (c.name, c.basedir(True), c.name, fixits_text) + "\n"
new_text_to_insert += " - [%s](%sREADME-%s.md)%s" % (c.name, docs_relative_path(), c.name, fixits_text) + "\n"
new_text_to_insert += "\n"
......@@ -477,6 +489,31 @@ def generate_readme(checks):
return True
return False
#-------------------------------------------------------------------------------
def generate_readmes_cmake_install(checks):
old_contents = ""
filename = clazy_source_path() + 'readmes.cmake'
if os.path.exists(filename):
f = io.open(filename, 'r', newline='\n', encoding='utf8')
old_contents = f.readlines();
f.close();
new_text_to_insert = ""
for level in ['-1', '0', '1', '2', '3']:
new_text_to_insert += 'SET(' + level_num_to_cmake_readme_variable(int(level)) + "\n"
for c in checks:
if str(c.level) == level:
new_text_to_insert += ' ${CMAKE_CURRENT_LIST_DIR}/docs/checks/' + c.readme_name() + '\n'
new_text_to_insert += ')\n\n'
if old_contents == new_text_to_insert:
return False
f = io.open(filename, 'w', newline='\n', encoding='utf8')
f.write(new_text_to_insert)
f.close()
return True
#-------------------------------------------------------------------------------
complete_json_filename = clazy_source_path() + CHECKS_FILENAME
......@@ -504,6 +541,7 @@ if args.generate:
generated = create_readmes(_checks) or generated
generated = create_unittests(_checks) or generated
generated = create_checks(_checks) or generated
generated = generate_readmes_cmake_install(_checks) or generated
if not generated:
print("Nothing to do, everything is OK")
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment