def METHOD_NAME(_):
  """Lint changed code."""
  pythonpath = os.getenv('PYTHONPATH', '')
  module_parent_path = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
  third_party_path = os.path.join(module_parent_path, 'third_party')
  os.environ['PYTHONPATH'] = ':'.join(
      [third_party_path, module_parent_path, pythonpath])
  if 'GOOGLE_CLOUDBUILD' in os.environ:
    # Explicitly compare against master if we're running on the CI
    _, output = common.METHOD_NAME('git diff --name-only master FETCH_HEAD')
  else:
    _, output = common.METHOD_NAME('git diff --name-only FETCH_HEAD')
  file_paths = [
      f.decode('utf-8') for f in output.splitlines() if os.path.exists(f)
  ]
  module_path = os.path.join(module_parent_path, 'clusterfuzz')
  py_changed_tests = []
  py_changed_noncf_module = []
  py_changed_nontests = []
  go_changed_file_paths = []
  yaml_changed_file_paths = []
  for file_path in file_paths:
    if file_path.endswith('.go'):
      go_changed_file_paths.append(file_path)
      continue
    if file_path.endswith('.yaml'):
      yaml_changed_file_paths.append(file_path)
      continue
    if not file_path.endswith('.py') or is_auto_generated_file(file_path):
      continue
    if file_path.endswith('_test.py'):
      py_changed_tests.append(file_path)
    else:
      py_changed_nontests.append(file_path)
    if not os.path.abspath(file_path).startswith(module_path):
      py_changed_noncf_module.append(file_path)
  # Use --score no to make output less noisy.
  base_pylint_cmd = 'pylint --score=no --jobs=0'
  # Test for existence of files before running tools to avoid errors from
  # misusing the tools.
  if py_changed_nontests:
    _execute_command_and_track_error(
        f'{base_pylint_cmd} --ignore=protos,tests,grammars clusterfuzz ' +
        ' '.join(py_changed_noncf_module))
  if py_changed_tests:
    _execute_command_and_track_error(
        f'{base_pylint_cmd} --ignore=protos,grammars --max-line-length=240 '
        '--disable no-member clusterfuzz._internal.tests')
  py_changed_file_paths = py_changed_nontests + py_changed_tests
  if py_changed_file_paths:
    _execute_command_and_track_error(
        f'yapf -p -d {" ".join(py_changed_file_paths)}')
    _execute_command_and_track_error(f'{formatter.ISORT_CMD} -c '
                                     f'{" ".join(py_changed_file_paths)}')
  for file_path in py_changed_file_paths:
    py_test_init_check(file_path)
  golint_path = os.path.join('local', 'bin', 'golint')
  for file_path in go_changed_file_paths:
    if not os.path.basename(file_path) in _GOLINT_EXCEPTIONS:
      _execute_command_and_track_error(golint_path + ' ' + file_path)
    output = _execute_command_and_track_error('gofmt -d ' + file_path)
    if output.strip():
      _error()
  for file_path in yaml_changed_file_paths:
    yaml_validate(file_path)
  for file_path in file_paths:
    license_validate(file_path)
  if _error_occurred:
    print('Linting failed, see errors above.')
    sys.exit(1)
  else:
    print('Linting passed.')