- Timestamp:
- 12/22/06 22:42:05 (6 years ago)
- Files:
-
- trunk/cheesecake/cheesecake_index.py (modified) (8 diffs)
- trunk/cheesecake/pep8.py (added)
- trunk/tests/unit/test_index_class.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cheesecake/cheesecake_index.py
r156 r159 33 33 from util import time_function 34 34 from codeparser import CodeParser 35 from cheesecake import __version__ as VERSION 35 from __init__ import __version__ as VERSION 36 import pep8 36 37 37 38 __docformat__ = 'reStructuredText en' … … 90 91 * special: .py file for special purposes 91 92 92 :Note: This function only check file's name, and doesn't touch the93 :Note: This function only checks file's name, and doesn't touch the 93 94 filesystem. If you have to, check if file exists by yourself. 94 95 … … 507 508 """ 508 509 if not isinstance(index, Index): 509 raise ValueError("subindex ha veto be instance of Index")510 raise ValueError("subindex has to be instance of Index") 510 511 511 512 self.subindices.append(index) … … 579 580 >>> opt_ext = WithOptionalExt('readme', ['html', 'txt']) 580 581 581 It means the same! (representation ha vea meaning)582 It means the same! (representation has a meaning) 582 583 >>> str(one_of) == str(opt_ext) 583 584 True … … 760 761 and how far from it actual package was. 761 762 762 Distance is number of links user ha veto follow to download763 Distance is number of links user has to follow to download 763 764 a given software package. 764 765 """ … … 989 990 990 991 class IndexUnitTested(Index): 991 """Check if the package ha veunit tests which can be easily found by992 """Check if the package has unit tests which can be easily found by 992 993 any of known test frameworks. 993 994 """ … … 1002 1003 1003 1004 if unittests_count > 0: 1004 self.add_info("Package ha vetests that inherit from unittest.TestCase.")1005 self.add_info("Package has tests that inherit from unittest.TestCase.") 1005 1006 unit_tested = True 1006 1007 1007 1008 if get_files_of_type(files_list, 'test'): 1008 self.add_info("Package ha vefilenames which probably contain tests (in format test_* or *_test)")1009 self.add_info("Package has filenames which probably contain tests (in format test_* or *_test)") 1009 1010 unit_tested = True 1010 1011 … … 1119 1120 return not cheesecake.lite 1120 1121 1122 class IndexPEP8(Index): 1123 """Compute PEP8 index for the modules in the package. 1124 """ 1125 name = "pep8" 1126 max_value = 0 1127 error_score = -2 1128 warning_score = -1 1129 1130 1131 def compute(self, files_list, package_dir): 1132 files_to_score = get_files_of_type(files_list, 'module') 1133 if len(files_to_score) == 0: 1134 self.value = 0 1135 self.details = "no modules found" 1136 return self.value 1137 1138 full_paths = [os.path.join(package_dir, file) for file in files_to_score] 1139 arglist = ["-qq"] + full_paths 1140 pep8.process_options(arglist) 1141 for file in files_to_score: 1142 fullpath = os.path.join(package_dir, file) 1143 pep8.input_file(fullpath) 1144 error_stats = pep8.get_error_statistics() 1145 warning_stats = pep8.get_warning_statistics() 1146 errors = len(error_stats) 1147 warnings = len(warning_stats) 1148 total_error_score = self.error_score * errors 1149 total_warning_score = self.warning_score * warnings 1150 score = total_error_score + total_warning_score 1151 1152 self.add_info("Errors:") 1153 self.add_info("Count Details") 1154 for stat in error_stats: 1155 self.add_info(stat) 1156 self.add_info("pep8.py found %d error types; we're scoring %d per error type" % (errors, self.error_score)) 1157 self.add_info("Error score: %d" % total_error_score) 1158 self.add_info("Warnings:") 1159 self.add_info("Count Details") 1160 for stat in warning_stats: 1161 self.add_info(stat) 1162 self.add_info("pep8.py found %d warning types; we're scoring %d per warning type" % (warnings, self.warning_score)) 1163 self.add_info("Warning score: %d" % total_warning_score) 1164 self.add_info("Total pep8 score: %d" % score) 1165 1166 self.value = score 1167 self.details = "pep8.py check: %d error types, %d warning types" % (errors, warnings) 1168 return self.value 1169 1121 1170 class IndexCodeKwalitee(Index): 1122 1171 name = "CODE KWALITEE" 1123 1172 1124 1173 subindices = [ 1125 IndexPyLint,1126 1174 #IndexUnitTests, 1127 1175 IndexUnitTested, 1176 IndexPyLint, 1177 IndexPEP8, 1128 1178 ] 1129 1179 trunk/tests/unit/test_index_class.py
r98 r159 35 35 Traceback (most recent call last): 36 36 ... 37 ValueError: subindex ha veto be instance of Index37 ValueError: subindex has to be instance of Index 38 38 39 39 Now remove subindex.
