15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#!/usr/bin/env python
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Copyright 2010 The Closure Linter Authors. All Rights Reserved.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Licensed under the Apache License, Version 2.0 (the "License");
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# you may not use this file except in compliance with the License.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# You may obtain a copy of the License at
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#      http://www.apache.org/licenses/LICENSE-2.0
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# Unless required by applicable law or agreed to in writing, software
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# distributed under the License is distributed on an "AS-IS" BASIS,
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# See the License for the specific language governing permissions and
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)# limitations under the License.
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)"""Linter error rules class for Closure Linter."""
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)__author__ = 'robbyw@google.com (Robert Walker)'
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)import gflags as flags
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)from closure_linter import errors
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)FLAGS = flags.FLAGS
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)flags.DEFINE_boolean('jsdoc', True,
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                     'Whether to report errors for missing JsDoc.')
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)def ShouldReportError(error):
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  """Whether the given error should be reported.
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  Returns:
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    True for all errors except missing documentation errors.  For these,
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    it returns the value of the jsdoc flag.
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  """
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return FLAGS.jsdoc or error not in (
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      errors.MISSING_PARAMETER_DOCUMENTATION,
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      errors.MISSING_RETURN_DOCUMENTATION,
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      errors.MISSING_MEMBER_DOCUMENTATION,
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      errors.MISSING_PRIVATE,
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      errors.MISSING_JSDOC_TAG_THIS)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)