<commit_before>#!/usr/bin/ruby

$lines = []
while l = gets
  $lines << l.strip
end

def parseline(line)
  if /(.+?)=(.+)/ =~ line then
    name = $1
    value = $2
    return [name.strip, value.strip.gsub(/;$/, '')]
  end
  return [nil, nil]
end

def check_value(name, value)
  isexist = false
  $lines.each do |l|
    (linename, linevalue) = parseline(l)
    if name == linename then
      isexist = true
      if value != linevalue then
        print "[ERROR] Invalid value: #{name} (#{linevalue} != #{value})\n"
        exit 1
      end
    end
  end
  unless isexist then
    print "[ERROR] No setting: #{name}\n"
    exit 1
  end
end

def check_noexist(name)
  $lines.each do |l|
    (linename, linevalue) = parseline(l)
    if name == linename then
      print "[ERROR] Appear name: #{name}\n"
      exit 1
    end
  end
end

check_value('ARCHS', '"$(ARCHS_STANDARD_32_64_BIT)"');
check_value('objectVersion', '46')
check_value('GCC_ENABLE_OBJC_GC', 'supported')
check_value('GCC_TREAT_WARNINGS_AS_ERRORS', 'YES')
check_value('GCC_WARN_64_TO_32_BIT_CONVERSION', 'YES')
check_value('GCC_WARN_ABOUT_MISSING_NEWLINE', 'YES')
check_value('GCC_WARN_ABOUT_MISSING_PROTOTYPES', 'YES')
check_value('GCC_WARN_ABOUT_RETURN_TYPE', 'YES')
check_value('GCC_WARN_CHECK_SWITCH_STATEMENTS', 'YES')
check_value('GCC_WARN_MISSING_PARENTHESES', 'YES')
check_value('GCC_WARN_SHADOW', 'YES')
check_value('GCC_WARN_SIGN_COMPARE', 'YES')
check_value('GCC_WARN_UNINITIALIZED_AUTOS', 'YES')
check_value('GCC_WARN_UNUSED_FUNCTION', 'YES')
check_value('GCC_WARN_UNUSED_LABEL', 'YES')
check_value('GCC_WARN_UNUSED_VALUE', 'YES')
check_value('GCC_WARN_UNUSED_VARIABLE', 'YES')
check_value('SDKROOT', 'macosx10.6')

check_noexist('GCC_WARN_PROTOTYPE_CONVERSION')
<commit_msg>update util/lint<commit_after>#!/usr/bin/ruby

$lines = []
while l = $stdin.gets
  $lines << l.strip
end

def parseline(line)
  if /(.+?)=(.+)/ =~ line then
    name = $1
    value = $2
    return [name.strip, value.strip.gsub(/;$/, '')]
  end
  return [nil, nil]
end

def check_value(name, value)
  return if ARGV.include?(name)
  print "  check #{name}\n"

  isexist = false
  $lines.each do |l|
    (linename, linevalue) = parseline(l)
    if name == linename then
      isexist = true
      if value != linevalue then
        print "[ERROR] Invalid value: #{name} (#{linevalue} != #{value})\n"
        exit 1
      end
    end
  end
  unless isexist then
    print "[ERROR] No setting: #{name}\n"
    exit 1
  end
end

def check_noexist(name)
  $lines.each do |l|
    (linename, linevalue) = parseline(l)
    if name == linename then
      print "[ERROR] Appear name: #{name}\n"
      exit 1
    end
  end
end

check_value('ARCHS', '"$(ARCHS_STANDARD_32_64_BIT)"');
check_value('objectVersion', '46')
check_value('GCC_ENABLE_OBJC_GC', 'unsupported')
check_value('GCC_TREAT_WARNINGS_AS_ERRORS', 'YES')
check_value('GCC_WARN_64_TO_32_BIT_CONVERSION', 'YES')
check_value('GCC_WARN_ABOUT_MISSING_NEWLINE', 'YES')
check_value('GCC_WARN_ABOUT_MISSING_PROTOTYPES', 'YES')
check_value('GCC_WARN_ABOUT_RETURN_TYPE', 'YES')
check_value('GCC_WARN_CHECK_SWITCH_STATEMENTS', 'YES')
check_value('GCC_WARN_MISSING_PARENTHESES', 'YES')
check_value('GCC_WARN_SHADOW', 'YES')
check_value('GCC_WARN_SIGN_COMPARE', 'YES')
check_value('GCC_WARN_UNINITIALIZED_AUTOS', 'YES')
check_value('GCC_WARN_UNUSED_FUNCTION', 'YES')
check_value('GCC_WARN_UNUSED_LABEL', 'YES')
check_value('GCC_WARN_UNUSED_VALUE', 'YES')
check_value('GCC_WARN_UNUSED_VARIABLE', 'YES')
check_value('RUN_CLANG_STATIC_ANALYZER', 'YES')
check_value('SDKROOT', 'macosx10.6')

check_noexist('GCC_WARN_PROTOTYPE_CONVERSION')

{'fraction_non_alphanumeric': 0.15015180789401048, 'fraction_numerical': 0.009936516698868341, 'mean_word_length': 5.173764906303237, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6502873', 'n_tokens_mistral': 1490, 'n_tokens_neox': 1381, 'n_words': 267}