components/subresource_filter/core/common/PRESUBMIT.py
def CheckIndexedRulesetVersion(input_api, output_api):
  """ Checks that IndexedRuleset format version is modified when necessary.

  Whenever any of the following files is changed:
   - components/subresource_filter/core/common/indexed_ruleset.cc
   - components/subresource_filter/core/common/flat/indexed_ruleset.fbs
  and kIndexedFormatVersion constant stays intact, this check returns a
  presubmit warning to make sure the value should not be updated.
  """

  indexed_ruleset_changed = False
  indexed_ruleset_version_changed = False

  for affected_file in input_api.AffectedFiles():
    path = affected_file.LocalPath()
    basename = input_api.basename(path)

    if basename == 'indexed_ruleset.cc' or basename == 'indexed_ruleset.fbs':
      indexed_ruleset_changed = True

    if basename == 'indexed_ruleset.cc':
      for (_, line) in affected_file.ChangedContents():
        if 'const int RulesetIndexer::kIndexedFormatVersion =' in line:
          indexed_ruleset_version_changed = True
          break

  # If the indexed ruleset version changed, ensure the perf benchmarks are using
  # the new format.
  out = []
  if indexed_ruleset_changed and not indexed_ruleset_version_changed:
    out.append(output_api.PresubmitPromptWarning(
        'Please make sure that IndexedRuleset modifications in '
        'indexed_ruleset.fbs and indexed_ruleset.cc do not require updating '
        'RulesetIndexer::kIndexedFormatVersion.'))

  return out
 Checks that IndexedRuleset format version is modified when necessary.

  Whenever any of the following files is changed:
   - components/subresource_filter/core/common/indexed_ruleset.cc
   - components/subresource_filter/core/common/flat/indexed_ruleset.fbs
  and kIndexedFormatVersion constant stays intact, this check returns a
  presubmit warning to make sure the value should not be updated.
  
Checks that IndexedRuleset format version is modified when necessary.
Checks that IndexedRuleset format version is modified when necessary .
def CheckIndexedRulesetVersion(input_api, output_api):
  indexed_ruleset_changed = False
  indexed_ruleset_version_changed = False
  for affected_file in input_api.AffectedFiles():
    path = affected_file.LocalPath()
    basename = input_api.basename(path)
    if basename == 'indexed_ruleset.cc' or basename == 'indexed_ruleset.fbs':
      indexed_ruleset_changed = True
    if basename == 'indexed_ruleset.cc':
      for (_, line) in affected_file.ChangedContents():
        if 'const int RulesetIndexer::kIndexedFormatVersion =' in line:
          indexed_ruleset_version_changed = True
          break
  out = []
  if indexed_ruleset_changed and not indexed_ruleset_version_changed:
    out.append(output_api.PresubmitPromptWarning(
        'Please make sure that IndexedRuleset modifications in '
        'indexed_ruleset.fbs and indexed_ruleset.cc do not require updating '
        'RulesetIndexer::kIndexedFormatVersion.'))
  return out
def CheckIndexedRulesetVersion ( input_api , output_api ) : indexed_ruleset_changed = False indexed_ruleset_version_changed = False for affected_file in input_api . AffectedFiles ( ) : path = affected_file . LocalPath ( ) basename = input_api . basename ( path ) if basename == 'indexed_ruleset.cc' or basename == 'indexed_ruleset.fbs' : indexed_ruleset_changed = True if basename == 'indexed_ruleset.cc' : for ( _ , line ) in affected_file . ChangedContents ( ) : if 'const int RulesetIndexer::kIndexedFormatVersion =' in line : indexed_ruleset_version_changed = True break out = [ ] if indexed_ruleset_changed and not indexed_ruleset_version_changed : out . append ( output_api . PresubmitPromptWarning ( 'Please make sure that IndexedRuleset modifications in ' 'indexed_ruleset.fbs and indexed_ruleset.cc do not require updating ' 'RulesetIndexer::kIndexedFormatVersion.' ) ) return out
Checks that IndexedRuleset format version is modified when necessary.
Checks that IndexedRuleset format version is modified when necessary .
""" Checks that IndexedRuleset format version is modified when necessary.

  Whenever any of the following files is changed:
   - components/subresource_filter/core/common/indexed_ruleset.cc
   - components/subresource_filter/core/common/flat/indexed_ruleset.fbs
  and kIndexedFormatVersion constant stays intact, this check returns a
  presubmit warning to make sure the value should not be updated.
  """ # If the indexed ruleset version changed, ensure the perf benchmarks are using # the new format.
input_api
output_api