1#!/usr/bin/env python
2#
3# Copyright 2010 The Closure Linter Authors. All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS-IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Linter error rules class for Closure Linter."""
18
19__author__ = 'robbyw@google.com (Robert Walker)'
20
21import gflags as flags
22from closure_linter import errors
23
24
25FLAGS = flags.FLAGS
26flags.DEFINE_boolean('jsdoc', True,
27                     'Whether to report errors for missing JsDoc.')
28
29
30def ShouldReportError(error):
31  """Whether the given error should be reported.
32
33  Returns:
34    True for all errors except missing documentation errors.  For these,
35    it returns the value of the jsdoc flag.
36  """
37  return FLAGS.jsdoc or error not in (
38      errors.MISSING_PARAMETER_DOCUMENTATION,
39      errors.MISSING_RETURN_DOCUMENTATION,
40      errors.MISSING_MEMBER_DOCUMENTATION,
41      errors.MISSING_PRIVATE,
42      errors.MISSING_JSDOC_TAG_THIS)
43