Changeset 172

Show
Ignore:
Timestamp:
02/04/07 08:34:54 (2 years ago)
Author:
mk
Message:

Made pep8 score non-negative.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cheesecake/cheesecake_index.py

    r170 r172  
    11251125    """ 
    11261126    name = "pep8" 
    1127     max_value = 0 
     1127 
     1128    # 
     1129    # Max value is a number of possible pep8 errors times 2, 
     1130    #   plus number of possible pep8 warnings. 
     1131    # 
     1132    # Currently pep8 module support 15 errors: 
     1133    #   E101, 
     1134    #   E111, E112, E113, 
     1135    #   E201, E202, E203, 
     1136    #   E211, 
     1137    #   E221, E222, 
     1138    #   E301, E302, E303, 
     1139    #   E401, 
     1140    #   E501 
     1141    # and 4 warnings: 
     1142    #   W191, 
     1143    #   W291, 
     1144    #   W601, 
     1145    #   W602 
     1146    # 
     1147    max_value = 34 
     1148 
    11281149    error_score = -2 
    11291150    warning_score = -1 
    1130  
    11311151 
    11321152    def compute(self, files_list, package_dir): 
     
    11451165        error_stats = pep8.get_error_statistics() 
    11461166        warning_stats = pep8.get_warning_statistics() 
     1167 
    11471168        errors = len(error_stats) 
    11481169        warnings = len(warning_stats) 
     1170 
    11491171        total_error_score = self.error_score * errors 
    11501172        total_warning_score = self.warning_score * warnings 
     1173 
    11511174        score = total_error_score + total_warning_score 
     1175        self.value = self.max_value + score 
    11521176 
    11531177        self.add_info("Errors:") 
     
    11631187        self.add_info("pep8.py found %d warning types; we're scoring %d per warning type" % (warnings, self.warning_score)) 
    11641188        self.add_info("Warning score: %d" % total_warning_score) 
    1165         self.add_info("Total pep8 score: %d" % score) 
    1166  
    1167         self.value = score 
     1189        self.add_info("Total pep8 score: %d - %d = %d" % (self.max_value, abs(score), self.value)) 
     1190 
    11681191        self.details = "pep8.py check: %d error types, %d warning types" % (errors, warnings) 
    11691192        return self.value