12da489cd246702bee5938545b18a6f710ed214bcJamie Gennis#!/usr/bin/env python
22da489cd246702bee5938545b18a6f710ed214bcJamie Gennis#
32da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# Copyright 2010 The Closure Linter Authors. All Rights Reserved.
42da489cd246702bee5938545b18a6f710ed214bcJamie Gennis#
52da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# Licensed under the Apache License, Version 2.0 (the "License");
62da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# you may not use this file except in compliance with the License.
72da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# You may obtain a copy of the License at
82da489cd246702bee5938545b18a6f710ed214bcJamie Gennis#
92da489cd246702bee5938545b18a6f710ed214bcJamie Gennis#      http://www.apache.org/licenses/LICENSE-2.0
102da489cd246702bee5938545b18a6f710ed214bcJamie Gennis#
112da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# Unless required by applicable law or agreed to in writing, software
122da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# distributed under the License is distributed on an "AS-IS" BASIS,
132da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# See the License for the specific language governing permissions and
152da489cd246702bee5938545b18a6f710ed214bcJamie Gennis# limitations under the License.
162da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
172da489cd246702bee5938545b18a6f710ed214bcJamie Gennis"""Linter error rules class for Closure Linter."""
182da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
192da489cd246702bee5938545b18a6f710ed214bcJamie Gennis__author__ = 'robbyw@google.com (Robert Walker)'
202da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
212da489cd246702bee5938545b18a6f710ed214bcJamie Gennisimport gflags as flags
222da489cd246702bee5938545b18a6f710ed214bcJamie Gennisfrom closure_linter import errors
232da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
242da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
252da489cd246702bee5938545b18a6f710ed214bcJamie GennisFLAGS = flags.FLAGS
262da489cd246702bee5938545b18a6f710ed214bcJamie Gennisflags.DEFINE_boolean('jsdoc', True,
272da489cd246702bee5938545b18a6f710ed214bcJamie Gennis                     'Whether to report errors for missing JsDoc.')
282da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
292da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
302da489cd246702bee5938545b18a6f710ed214bcJamie Gennisdef ShouldReportError(error):
312da489cd246702bee5938545b18a6f710ed214bcJamie Gennis  """Whether the given error should be reported.
322da489cd246702bee5938545b18a6f710ed214bcJamie Gennis
332da489cd246702bee5938545b18a6f710ed214bcJamie Gennis  Returns:
342da489cd246702bee5938545b18a6f710ed214bcJamie Gennis    True for all errors except missing documentation errors.  For these,
352da489cd246702bee5938545b18a6f710ed214bcJamie Gennis    it returns the value of the jsdoc flag.
362da489cd246702bee5938545b18a6f710ed214bcJamie Gennis  """
372da489cd246702bee5938545b18a6f710ed214bcJamie Gennis  return FLAGS.jsdoc or error not in (
382da489cd246702bee5938545b18a6f710ed214bcJamie Gennis      errors.MISSING_PARAMETER_DOCUMENTATION,
392da489cd246702bee5938545b18a6f710ed214bcJamie Gennis      errors.MISSING_RETURN_DOCUMENTATION,
402da489cd246702bee5938545b18a6f710ed214bcJamie Gennis      errors.MISSING_MEMBER_DOCUMENTATION,
412da489cd246702bee5938545b18a6f710ed214bcJamie Gennis      errors.MISSING_PRIVATE,
422da489cd246702bee5938545b18a6f710ed214bcJamie Gennis      errors.MISSING_JSDOC_TAG_THIS)
43