Coverage for pyquickhelper/pycode/_pylint_common.py: 69%

16 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-03 02:21 +0200

1""" 

2@file 

3@brief Check code style. 

4""" 

5import os 

6from .utils_tests_helper import check_pep8 

7 

8 

9def _run_cmd_filter(name): 

10 if "yaml_helper_yaml.py" in name: 

11 return True 

12 if "test_yaml.py" in name: 

13 return True 

14 return False 

15 

16 

17def _private_test_style_src(fLOG, run_lint, verbose=False, pattern=".*[.]py$"): 

18 thi = os.path.abspath(os.path.dirname(__file__)) 

19 src_ = os.path.normpath(os.path.join(thi, "..", "..")) 

20 check_pep8(src_, fLOG=fLOG, run_lint=run_lint, verbose=verbose, pattern=pattern, 

21 run_cmd_filter=_run_cmd_filter, 

22 pylint_ignore=('C0103', 'C1801', 'R1705', 'W0108', 'W0613', 

23 'W0201', 'W0212', 'W0603', 'W0622', 

24 'W0511', 'C0412', 'R1702', 'E0702', 

25 'W0640', 'C0111', 'R0914', 'C0302', 

26 'W0703', 'C0325', 'R1703', 'R0915', 

27 'R0912', 'W0123', 'R0913', 'R0912', 

28 'R0911', 'R0916', 'C0200', 'W0223', 

29 'W0122', 'E1003', 'R0205', 'E0001', 

30 'W0143', 'W0107', 'C0415', 'W1202', 

31 'W0707', 'R1725', 'R1732', 'W1514', 

32 'C0123', 'C0208', 'W1514', 'R1735', 

33 'R1734', 'C0209', 'W0602', 'C3001', 

34 'R1728', 'C2801'), 

35 skip=["windows_scripts.py", 

36 "Redefining built-in 'format'", 

37 "sphinx_md_builder.py", 

38 "sphinx_rst_builder.py", 

39 "Unused variable 'plt'", 

40 "Unused variable 'toctitle'", 

41 "ftp_transfer.py", 

42 "Redefining name 'fLOG' from outer scope", 

43 "Instance of '_MemoryBuilder' has no ", 

44 "Use % formatting in logging functions", 

45 "Class 'BlogPostListDirective' has no 'blogpostlist' member", 

46 "Instance of 'BlogPost' has no '", 

47 "Unable to import 'pyquickhelper.pycode.get_pip'", 

48 "Redefining name 'rss_update_run_server' from outer scope", 

49 "Unable to import 'pysvn'", 

50 "Instance of '_AdditionalVisitDepart' has no '", 

51 "Instance of '_WriterWithCustomDirectives' has no ", 

52 "No name 'brown' in module 'sphinx.util.console'", 

53 "Redefining argument with the local name 'dir'", 

54 "No name 'svg2png' in module 'cairosvg'", 

55 "No name 'bold' in module 'sphinx.util.console'", 

56 "No name 'darkgreen' in module 'sphinx.util.console'", 

57 "Redefining name 'HTMLTranslator' from outer scope", 

58 "Redefining name 'LaTeXTranslator' from outer scope", 

59 "Unused variable 'sphinx.builders.latex.transforms'", 

60 "Class 'Theme' has no 'themes' member", 

61 "Instance of 'MockSphinxApp' has no '_added_objects' member", 

62 "Unused import sphinx.builders.latex.transforms", 

63 "Unable to import 'pyquickhelper.helpgen.sphinxm_mock_app'", 

64 "No name 'sphinxm_mock_app' in module 'pyquickhelper.helpgen'", 

65 "W0641: Possibly unused variable", 

66 "[E731] do not assign a lambda expression, use a def", 

67 "cli_helper.py:196", 

68 "magic_parser.py:154: C0123: Using type() instead of isinstance()", 

69 "sphinxm_convert_doc_sphinx_helper.py:1595: [E128]", 

70 ]) 

71 

72 

73def _private_test_style_test(fLOG, run_lint, verbose=False, pattern=".*[.]py$"): 

74 thi = os.path.abspath(os.path.dirname(__file__)) 

75 test_ = os.path.normpath(os.path.join(thi, "..", "..", '..', '_unittests')) 

76 check_pep8(test_, fLOG=fLOG, neg_pattern="((temp[0-9]?_.*)|(.*((_venv)|(sphinxdoc)|([.]git)|(__pycache__)).*))", 

77 pattern=pattern, max_line_length=200, run_lint=run_lint, verbose=verbose, 

78 run_cmd_filter=_run_cmd_filter, 

79 pylint_ignore=('C0111', 'C0103', 'R0914', 'W0212', 'C0413', 'W0621', 

80 'W0703', 'W0622', 'W0122', 'R0912', 

81 'W0613', 'C0123', 'W0640', 'E0202', 'C0412', 

82 'R1702', 'W0612', 'C0411', 'E1101', 'W0719', 

83 'W0201', 'E0702', 'W1503', 'C0102', 'W0223', 

84 'W0611', 'R1705', 'W0631', 'W0102', 'R0205', 

85 'W0107', 'C0415', 'W1202', 'W0707', 'R1725', 

86 'R1732', 'W1514', 'C0208', 'R1735', 'W0632', 

87 'R1734', 'C0209', 'C3001', 'R1728', 'C2801'), 

88 skip=["skip_' imported but unused", 

89 "skip__' imported but unused", 

90 "skip___' imported but unused", 

91 "2test_download_pip.py", 

92 "[E402] module ", 

93 "Unused variable 'skip_", 

94 "imported as skip_", 

95 "Unable to import 'StringIO'", 

96 "Redefining built-in 'open'", 

97 "Do not use `len(SEQUENCE)`", 

98 "Unused variable 'fig'", 

99 "ut_sphinxext\\data", 

100 "ut_helpgen\\data", 

101 "ut_sphinxext/data", 

102 "ut_helpgen/data", 

103 "Unused argument 'node'", 

104 "Redefining built-in 'FileNotFoundError'", 

105 "Unable to import 'pyquickhelper", 

106 "Unable to import 'jyquickhelper", 

107 "Unable to import 'exsig'", 

108 "Unable to import 'pyquickhelper.helpgen.sphinxm_mock_app'", 

109 "Unable to import 'pyquickhelper.jenkinshelper", 

110 "Unable to import 'pyquickhelper", 

111 "No name 'sphinxm_mock_app' in module 'pyquickhelper.helpgen'", 

112 "test_yaml.py:333: [E501]", 

113 "test_yaml.py:337: [E501]", 

114 "test_yaml.py:339: [E501]", 

115 "test_yaml.py:345: [E501]", 

116 "test_yaml.py:347: [E501]", 

117 "test_yaml.py:341: [E501]", 

118 "test_yaml.py:343: [E501]", 

119 ])