code: def check(codeString, filename, reporter=None):
      
      if reporter is None:
          reporter = modReporter._makeDefaultReporter()
      # First, compile into an AST and handle syntax errors.
      try:
          tree = ast.parse(codeString, filename=filename)
      except SyntaxError:
          value = sys.exc_info()[1]
          msg = value.args[0]
  
          (lineno, offset, text) = value.lineno, value.offset, value.text
  
          if checker.PYPY:
              if text is None:
                  lines = codeString.splitlines()
                  if len(lines) >= lineno:
                      text = lines[lineno - 1]
                      if sys.version_info >= (3, ) and isinstance(text, bytes):
                          try:
                              text = text.decode('ascii')
                          except UnicodeDecodeError:
                              text = None
              offset -= 1
  
          # If there's an encoding problem with the file, the text is None.
          if text is None:
              # Avoid using msg, since for the only known case, it contains a
              # bogus message that claims the encoding the file declared was
              # unknown.
              reporter.unexpectedError(filename, 'problem decoding source')
          else:
              reporter.syntaxError(filename, msg, lineno, offset, text)
          return 1
      except Exception:
          reporter.unexpectedError(filename, 'problem decoding source')
          return 1
      # Okay, it's syntactically valid.  Now check it.
      file_tokens = checker.make_tokens(codeString)
      w = checker.Checker(tree, file_tokens=file_tokens, filename=filename)
      w.messages.sort(key=lambda m: m.lineno)
      for warning in w.messages:
          reporter.flake(warning)
      return len(w.messages)
docs: Check the Python source given by C{codeString} for flakes.
  
      @param codeString: The Python source to check.
      @type codeString: C{str}
  
      @param filename: The name of the file the source came from, used to report
          errors.
      @type filename: C{str}
  
      @param reporter: A L{Reporter} instance, where errors and warnings will be
          reported.
  
      @return: The number of warnings emitted.
      @rtype: C{int}