808 |
808 |
809 nonEmptyLines = [l.rstrip() for l in lines[1:] if l.strip()] |
809 nonEmptyLines = [l.rstrip() for l in lines[1:] if l.strip()] |
810 if not nonEmptyLines: |
810 if not nonEmptyLines: |
811 return |
811 return |
812 |
812 |
813 indent = min([len(l) - len(l.strip()) for l in nonEmptyLines]) |
813 indent = min(len(l) - len(l.strip()) for l in nonEmptyLines) |
814 if context.contextType() == "module": |
814 if context.contextType() == "module": |
815 expectedIndent = 0 |
815 expectedIndent = 0 |
816 else: |
816 else: |
817 expectedIndent = len(context.indent()) + 4 |
817 expectedIndent = len(context.indent()) + 4 |
818 if indent != expectedIndent: |
818 if indent != expectedIndent: |
895 tokens = list( |
895 tokens = list( |
896 tokenize.generate_tokens(StringIO(context.ssource()).readline)) |
896 tokenize.generate_tokens(StringIO(context.ssource()).readline)) |
897 return_ = [tokens[i + 1][0] for i, token in enumerate(tokens) |
897 return_ = [tokens[i + 1][0] for i, token in enumerate(tokens) |
898 if token[1] == "return"] |
898 if token[1] == "return"] |
899 if (set(return_) - |
899 if (set(return_) - |
900 set([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE]) != |
900 {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != |
901 set([])): |
901 set()): |
902 self.__error(docstringContext.end(), 0, "D134") |
902 self.__error(docstringContext.end(), 0, "D134") |
903 |
903 |
904 def __checkNoBlankLineBefore(self, docstringContext, context): |
904 def __checkNoBlankLineBefore(self, docstringContext, context): |
905 """ |
905 """ |
906 Private method to check, that function/method docstrings are not |
906 Private method to check, that function/method docstrings are not |
1060 tokenize.generate_tokens(StringIO(context.ssource()).readline)) |
1060 tokenize.generate_tokens(StringIO(context.ssource()).readline)) |
1061 return_ = [tokens[i + 1][0] for i, token in enumerate(tokens) |
1061 return_ = [tokens[i + 1][0] for i, token in enumerate(tokens) |
1062 if token[1] in ("return", "yield")] |
1062 if token[1] in ("return", "yield")] |
1063 if "@return" not in docstringContext.ssource(): |
1063 if "@return" not in docstringContext.ssource(): |
1064 if (set(return_) - |
1064 if (set(return_) - |
1065 set([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE]) != |
1065 {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != |
1066 set([])): |
1066 set()): |
1067 self.__error(docstringContext.end(), 0, "D234") |
1067 self.__error(docstringContext.end(), 0, "D234") |
1068 else: |
1068 else: |
1069 if (set(return_) - |
1069 if (set(return_) - |
1070 set([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE]) == |
1070 {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} == |
1071 set([])): |
1071 set()): |
1072 self.__error(docstringContext.end(), 0, "D235") |
1072 self.__error(docstringContext.end(), 0, "D235") |
1073 |
1073 |
1074 def __checkEricFunctionArguments(self, docstringContext, context): |
1074 def __checkEricFunctionArguments(self, docstringContext, context): |
1075 """ |
1075 """ |
1076 Private method to check, that docstrings contain an @param and/or |
1076 Private method to check, that docstrings contain an @param and/or |
1139 if token[1] == "raise"] |
1139 if token[1] == "raise"] |
1140 if "@exception" not in docstringContext.ssource() and \ |
1140 if "@exception" not in docstringContext.ssource() and \ |
1141 "@throws" not in docstringContext.ssource() and \ |
1141 "@throws" not in docstringContext.ssource() and \ |
1142 "@raise" not in docstringContext.ssource(): |
1142 "@raise" not in docstringContext.ssource(): |
1143 if (set(exception) - |
1143 if (set(exception) - |
1144 set([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE]) != |
1144 {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} != |
1145 set([])): |
1145 set()): |
1146 self.__error(docstringContext.end(), 0, "D250") |
1146 self.__error(docstringContext.end(), 0, "D250") |
1147 else: |
1147 else: |
1148 if (set(exception) - |
1148 if (set(exception) - |
1149 set([tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE]) == |
1149 {tokenize.COMMENT, tokenize.NL, tokenize.NEWLINE} == |
1150 set([])): |
1150 set()): |
1151 self.__error(docstringContext.end(), 0, "D251") |
1151 self.__error(docstringContext.end(), 0, "D251") |
1152 |
1152 |
1153 def __checkEricBlankAfterSummary(self, docstringContext, context): |
1153 def __checkEricBlankAfterSummary(self, docstringContext, context): |
1154 """ |
1154 """ |
1155 Private method to check, that docstring summaries are followed |
1155 Private method to check, that docstring summaries are followed |