parameters: (self, state, tokenizer_mode)
docstring: Perform all checks that need to occur after all lines are processed.
docstring_summary: Perform all checks that need to occur after all lines are processed.
docstring_tokens: Perform all checks that need to occur after all lines are processed .
function: def Finalize(self, state, tokenizer_mode):
      """Perform all checks that need to occur after all lines are processed."""
      # Call the base class's Finalize function.
      super(JavaScriptLintRules, self).Finalize(state, tokenizer_mode)
  
      # Check for sorted requires statements.
      goog_require_tokens = state.GetGoogRequireTokens()
      requires = [require_token.string for require_token in goog_require_tokens]
      sorted_requires = sorted(requires)
      index = 0
      bad = False
      for item in requires:
        if item != sorted_requires[index]:
          bad = True
          break
        index += 1
  
      if bad:
        self._HandleError(
            errors.GOOG_REQUIRES_NOT_ALPHABETIZED,
            'goog.require classes must be alphabetized.  The correct code is:\n' +
            '\n'.join(map(lambda x: 'goog.require(\'%s\');' % x,
                          sorted_requires)),
            goog_require_tokens[index],
            position=Position.AtBeginning(),
            fix_data=goog_require_tokens)
  
      # Check for sorted provides statements.
      goog_provide_tokens = state.GetGoogProvideTokens()
      provides = [provide_token.string for provide_token in goog_provide_tokens]
      sorted_provides = sorted(provides)
      index = 0
      bad = False
      for item in provides:
        if item != sorted_provides[index]:
          bad = True
          break
        index += 1
  
      if bad:
        self._HandleError(
            errors.GOOG_PROVIDES_NOT_ALPHABETIZED,
            'goog.provide classes must be alphabetized.  The correct code is:\n' +
            '\n'.join(map(lambda x: 'goog.provide(\'%s\');' % x,
                          sorted_provides)),
            goog_provide_tokens[index],
            position=Position.AtBeginning(),
            fix_data=goog_provide_tokens)
  
      if FLAGS.closurized_namespaces:
        # Check that we provide everything we need.
        provided_namespaces = state.GetProvidedNamespaces()
        missing_provides = provided_namespaces - set(provides)
        if missing_provides:
          self._HandleError(
              errors.MISSING_GOOG_PROVIDE,
              'Missing the following goog.provide statements:\n' +
              '\n'.join(map(lambda x: 'goog.provide(\'%s\');' % x,
                            sorted(missing_provides))),
              state.GetFirstToken(), position=Position.AtBeginning(),
              fix_data=missing_provides)
  
        # Compose a set of all available namespaces. Explicitly omit goog
        # because if you can call goog.require, you already have goog.
        available_namespaces = (set(requires) | set(provides) | set(['goog']) |
                                provided_namespaces)
  
        # Check that we require everything we need.
        missing_requires = set()
        for namespace_variants in state.GetUsedNamespaces():
          # Namespace variants is a list of potential things to require. If we
          # find we're missing one, we are lazy and choose to require the first
          # in the sequence - which should be the namespace.
          if not set(namespace_variants) & available_namespaces:
            missing_requires.add(namespace_variants[0])
  
        if missing_requires:
          self._HandleError(
              errors.MISSING_GOOG_REQUIRE,
              'Missing the following goog.require statements:\n' +
              '\n'.join(map(lambda x: 'goog.require(\'%s\');' % x,
                            sorted(missing_requires))),
              state.GetFirstToken(), position=Position.AtBeginning(),
              fix_data=missing_requires)
  
        # Check that we don't require things we don't actually use.
        namespace_variants = state.GetUsedNamespaces()
        used_namespaces = set()
        for a, b in namespace_variants:
          used_namespaces.add(a)
          used_namespaces.add(b)
  
        extra_requires = set()
        for i in requires:
          baseNamespace = i.split('.')[0]
          if (i not in used_namespaces and
              baseNamespace in FLAGS.closurized_namespaces and
              i not in FLAGS.ignored_extra_namespaces):
            extra_requires.add(i)
  
        if extra_requires:
          self._HandleError(
              errors.EXTRA_GOOG_REQUIRE,
              'The following goog.require statements appear unnecessary:\n' +
              '\n'.join(map(lambda x: 'goog.require(\'%s\');' % x,
                            sorted(extra_requires))),
              state.GetFirstToken(), position=Position.AtBeginning(),
              fix_data=extra_requires)
function_tokens: def Finalize ( self , state , tokenizer_mode ) : # Call the base class's Finalize function. super ( JavaScriptLintRules , self ) . Finalize ( state , tokenizer_mode ) # Check for sorted requires statements. goog_require_tokens = state . GetGoogRequireTokens ( ) requires = [ require_token . string for require_token in goog_require_tokens ] sorted_requires = sorted ( requires ) index = 0 bad = False for item in requires : if item != sorted_requires [ index ] : bad = True break index += 1 if bad : self . _HandleError ( errors . GOOG_REQUIRES_NOT_ALPHABETIZED , 'goog.require classes must be alphabetized.  The correct code is:\n' + '\n' . join ( map ( lambda x : 'goog.require(\'%s\');' % x , sorted_requires ) ) , goog_require_tokens [ index ] , position = Position . AtBeginning ( ) , fix_data = goog_require_tokens ) # Check for sorted provides statements. goog_provide_tokens = state . GetGoogProvideTokens ( ) provides = [ provide_token . string for provide_token in goog_provide_tokens ] sorted_provides = sorted ( provides ) index = 0 bad = False for item in provides : if item != sorted_provides [ index ] : bad = True break index += 1 if bad : self . _HandleError ( errors . GOOG_PROVIDES_NOT_ALPHABETIZED , 'goog.provide classes must be alphabetized.  The correct code is:\n' + '\n' . join ( map ( lambda x : 'goog.provide(\'%s\');' % x , sorted_provides ) ) , goog_provide_tokens [ index ] , position = Position . AtBeginning ( ) , fix_data = goog_provide_tokens ) if FLAGS . closurized_namespaces : # Check that we provide everything we need. provided_namespaces = state . GetProvidedNamespaces ( ) missing_provides = provided_namespaces - set ( provides ) if missing_provides : self . _HandleError ( errors . MISSING_GOOG_PROVIDE , 'Missing the following goog.provide statements:\n' + '\n' . join ( map ( lambda x : 'goog.provide(\'%s\');' % x , sorted ( missing_provides ) ) ) , state . GetFirstToken ( ) , position = Position . AtBeginning ( ) , fix_data = missing_provides ) # Compose a set of all available namespaces. Explicitly omit goog # because if you can call goog.require, you already have goog. available_namespaces = ( set ( requires ) | set ( provides ) | set ( [ 'goog' ] ) | provided_namespaces ) # Check that we require everything we need. missing_requires = set ( ) for namespace_variants in state . GetUsedNamespaces ( ) : # Namespace variants is a list of potential things to require. If we # find we're missing one, we are lazy and choose to require the first # in the sequence - which should be the namespace. if not set ( namespace_variants ) & available_namespaces : missing_requires . add ( namespace_variants [ 0 ] ) if missing_requires : self . _HandleError ( errors . MISSING_GOOG_REQUIRE , 'Missing the following goog.require statements:\n' + '\n' . join ( map ( lambda x : 'goog.require(\'%s\');' % x , sorted ( missing_requires ) ) ) , state . GetFirstToken ( ) , position = Position . AtBeginning ( ) , fix_data = missing_requires ) # Check that we don't require things we don't actually use. namespace_variants = state . GetUsedNamespaces ( ) used_namespaces = set ( ) for a , b in namespace_variants : used_namespaces . add ( a ) used_namespaces . add ( b ) extra_requires = set ( ) for i in requires : baseNamespace = i . split ( '.' ) [ 0 ] if ( i not in used_namespaces and baseNamespace in FLAGS . closurized_namespaces and i not in FLAGS . ignored_extra_namespaces ) : extra_requires . add ( i ) if extra_requires : self . _HandleError ( errors . EXTRA_GOOG_REQUIRE , 'The following goog.require statements appear unnecessary:\n' + '\n' . join ( map ( lambda x : 'goog.require(\'%s\');' % x , sorted ( extra_requires ) ) ) , state . GetFirstToken ( ) , position = Position . AtBeginning ( ) , fix_data = extra_requires )