1#!/usr/bin/env python 2# Copyright 2007 The Closure Linter Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS-IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16"""Error codes for JavaScript style checker.""" 17 18__author__ = ('robbyw@google.com (Robert Walker)', 19 'ajp@google.com (Andy Perelson)') 20 21 22def ByName(name): 23 """Get the error code for the given error name. 24 25 Args: 26 name: The name of the error 27 28 Returns: 29 The error code 30 """ 31 return globals()[name] 32 33 34# "File-fatal" errors - these errors stop further parsing of a single file 35FILE_NOT_FOUND = -1 36FILE_DOES_NOT_PARSE = -2 37 38# Spacing 39EXTRA_SPACE = 1 40MISSING_SPACE = 2 41EXTRA_LINE = 3 42MISSING_LINE = 4 43ILLEGAL_TAB = 5 44WRONG_INDENTATION = 6 45WRONG_BLANK_LINE_COUNT = 7 46 47# Semicolons 48MISSING_SEMICOLON = 10 49MISSING_SEMICOLON_AFTER_FUNCTION = 11 50ILLEGAL_SEMICOLON_AFTER_FUNCTION = 12 51REDUNDANT_SEMICOLON = 13 52 53# Miscellaneous 54ILLEGAL_PROTOTYPE_MEMBER_VALUE = 100 55LINE_TOO_LONG = 110 56LINE_STARTS_WITH_OPERATOR = 120 57COMMA_AT_END_OF_LITERAL = 121 58LINE_ENDS_WITH_DOT = 122 59MULTI_LINE_STRING = 130 60UNNECESSARY_DOUBLE_QUOTED_STRING = 131 61UNUSED_PRIVATE_MEMBER = 132 62UNUSED_LOCAL_VARIABLE = 133 63 64# Requires, provides 65GOOG_REQUIRES_NOT_ALPHABETIZED = 140 66GOOG_PROVIDES_NOT_ALPHABETIZED = 141 67MISSING_GOOG_REQUIRE = 142 68MISSING_GOOG_PROVIDE = 143 69EXTRA_GOOG_REQUIRE = 144 70EXTRA_GOOG_PROVIDE = 145 71ALIAS_STMT_NEEDS_GOOG_REQUIRE = 146 72 73# JsDoc 74INVALID_JSDOC_TAG = 200 75INVALID_USE_OF_DESC_TAG = 201 76NO_BUG_NUMBER_AFTER_BUG_TAG = 202 77MISSING_PARAMETER_DOCUMENTATION = 210 78EXTRA_PARAMETER_DOCUMENTATION = 211 79WRONG_PARAMETER_DOCUMENTATION = 212 80MISSING_JSDOC_TAG_TYPE = 213 81MISSING_JSDOC_TAG_DESCRIPTION = 214 82MISSING_JSDOC_PARAM_NAME = 215 83OUT_OF_ORDER_JSDOC_TAG_TYPE = 216 84MISSING_RETURN_DOCUMENTATION = 217 85UNNECESSARY_RETURN_DOCUMENTATION = 218 86MISSING_BRACES_AROUND_TYPE = 219 87MISSING_MEMBER_DOCUMENTATION = 220 88MISSING_PRIVATE = 221 89EXTRA_PRIVATE = 222 90INVALID_OVERRIDE_PRIVATE = 223 91INVALID_INHERIT_DOC_PRIVATE = 224 92MISSING_JSDOC_TAG_THIS = 225 93UNNECESSARY_BRACES_AROUND_INHERIT_DOC = 226 94INVALID_AUTHOR_TAG_DESCRIPTION = 227 95JSDOC_PREFER_QUESTION_TO_PIPE_NULL = 230 96JSDOC_ILLEGAL_QUESTION_WITH_PIPE = 231 97JSDOC_MISSING_OPTIONAL_TYPE = 232 98JSDOC_MISSING_OPTIONAL_PREFIX = 233 99JSDOC_MISSING_VAR_ARGS_TYPE = 234 100JSDOC_MISSING_VAR_ARGS_NAME = 235 101JSDOC_DOES_NOT_PARSE = 236 102# TODO(robbyw): Split this in to more specific syntax problems. 103INCORRECT_SUPPRESS_SYNTAX = 250 104INVALID_SUPPRESS_TYPE = 251 105UNNECESSARY_SUPPRESS = 252 106 107# File ending 108FILE_MISSING_NEWLINE = 300 109FILE_IN_BLOCK = 301 110 111# Interfaces 112INTERFACE_CONSTRUCTOR_CANNOT_HAVE_PARAMS = 400 113INTERFACE_METHOD_CANNOT_HAVE_CODE = 401 114 115# Comments 116MISSING_END_OF_SCOPE_COMMENT = 500 117MALFORMED_END_OF_SCOPE_COMMENT = 501 118 119# goog.scope - Namespace aliasing 120# TODO(nnaze) Add additional errors here and in aliaspass.py 121INVALID_USE_OF_GOOG_SCOPE = 600 122EXTRA_GOOG_SCOPE_USAGE = 601 123 124# ActionScript specific errors: 125# TODO(user): move these errors to their own file and move all JavaScript 126# specific errors to their own file as well. 127# All ActionScript specific errors should have error number at least 1000. 128FUNCTION_MISSING_RETURN_TYPE = 1132 129PARAMETER_MISSING_TYPE = 1133 130VAR_MISSING_TYPE = 1134 131PARAMETER_MISSING_DEFAULT_VALUE = 1135 132IMPORTS_NOT_ALPHABETIZED = 1140 133IMPORT_CONTAINS_WILDCARD = 1141 134UNUSED_IMPORT = 1142 135INVALID_TRACE_SEVERITY_LEVEL = 1250 136MISSING_TRACE_SEVERITY_LEVEL = 1251 137MISSING_TRACE_MESSAGE = 1252 138REMOVE_TRACE_BEFORE_SUBMIT = 1253 139REMOVE_COMMENT_BEFORE_SUBMIT = 1254 140# End of list of ActionScript specific errors. 141 142NEW_ERRORS = frozenset([ 143 # Errors added after 2.0.2: 144 WRONG_INDENTATION, 145 MISSING_SEMICOLON, 146 # Errors added after 2.3.9: 147 JSDOC_MISSING_VAR_ARGS_TYPE, 148 JSDOC_MISSING_VAR_ARGS_NAME, 149 # Errors added after 2.3.15: 150 ALIAS_STMT_NEEDS_GOOG_REQUIRE, 151 JSDOC_DOES_NOT_PARSE, 152 LINE_ENDS_WITH_DOT, 153 # Errors added after 2.3.19: 154 ]) 155