<commit_before># ==================================================================================================
# Copyright 2012 Twitter, Inc.
# --------------------------------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==================================================================================================
import os

__author__ = '<NAME>'

import difflib
import re

from collections import defaultdict

from twitter.pants.tasks import Task


class BuildLint(Task):
  @classmethod
  def setup_parser(cls, option_group, args, mkflag):
    Task.setup_parser(option_group, args, mkflag)

    option_group.add_option(mkflag("transitive"), mkflag("transitive", negate=True),
      dest="buildlint_transitive", default=False,
      action="callback", callback=mkflag.set_bool,
      help="[%default] apply lint rules transitively to all dependency buildfiles.")

    option_group.add_option(mkflag("include-intransitive-deps"),
      mkflag("include-intransitive-deps", negate=True),
      dest="buildlint_include_intransitive", default=False,
      action="callback", callback=mkflag.set_bool,
      help="[%default] correct both simple missing dependencies and intransitive missing deps")


    option_group.add_option(mkflag("action"), dest="buildlint_actions", default=[],
      action="append", type="choice", choices=['diff', 'rewrite'],
      help="diff=print out diffs, rewrite=apply changes to BUILD files directly.")

  def __init__(self, context):
    Task.__init__(self, context)
    context.products.require('missing_deps')
    self.transitive = context.options.buildlint_transitive
    self.actions = set(context.options.buildlint_actions)
    self.include_intransitive = context.options.builtlint_include_intransitive
    # Manually apply the default. Can't use flag default, because action is 'append', so
    # diffs would always be printed, even if we only wanted to rewrite.
    if not self.actions:
      self.actions.add('diff')

  def execute(self, targets):
    # Map from buildfile path to map of target name -> missing deps for that target.
    buildfile_paths = defaultdict(lambda: defaultdict(list))
    genmap_trans = self.context.products.get('missing_deps')<commit_msg>Fix misspelling<commit_after># ==================================================================================================
# Copyright 2012 Twitter, Inc.
# --------------------------------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==================================================================================================
import os

__author__ = '<NAME>'

import difflib
import re

from collections import defaultdict

from twitter.pants.tasks import Task


class BuildLint(Task):
  @classmethod
  def setup_parser(cls, option_group, args, mkflag):
    Task.setup_parser(option_group, args, mkflag)

    option_group.add_option(mkflag("transitive"), mkflag("transitive", negate=True),
      dest="buildlint_transitive", default=False,
      action="callback", callback=mkflag.set_bool,
      help="[%default] apply lint rules transitively to all dependency buildfiles.")

    option_group.add_option(mkflag("include-intransitive-deps"),
      mkflag("include-intransitive-deps", negate=True),
      dest="buildlint_include_intransitive", default=False,
      action="callback", callback=mkflag.set_bool,
      help="[%default] correct both simple missing dependencies and intransitive missing deps")


    option_group.add_option(mkflag("action"), dest="buildlint_actions", default=[],
      action="append", type="choice", choices=['diff', 'rewrite'],
      help="diff=print out diffs, rewrite=apply changes to BUILD files directly.")

  def __init__(self, context):
    Task.__init__(self, context)
    context.products.require('missing_deps')
    self.transitive = context.options.buildlint_transitive
    self.actions = set(context.options.buildlint_actions)
    self.include_intransitive = context.options.buildlint_include_intransitive
    # Manually apply the default. Can't use flag default, because action is 'append', so
    # diffs would always be printed, even if we only wanted to rewrite.
    if not self.actions:
      self.actions.add('diff')

  def execute(self, targets):
    # Map from buildfile path to map of target name -> missing deps for that target.
    buildfile_paths = defaultdict(lambda: defaultdict(list))
    genmap_trans = self.context.products.get('missing_deps')
{'fraction_non_alphanumeric': 0.1937901498929336, 'fraction_numerical': 0.0028551034975017845, 'mean_word_length': 4.1706642066420665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5441495', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1399, 'n_words': 454}