<commit_before>module SCSSLint
  # Checks for misspelled properties.
  class Linter::PropertySpelling < Linter
    include LinterRegistry

    KNOWN_PROPERTIES = File.open(File.join(SCSS_LINT_DATA, 'properties.txt'))
                           .read
                           .split
                           .to_set

    def visit_root(_node)
      @extra_properties = Array(config['extra_properties']).to_set
      @disabled_properties = Array(config['disabled_properties']).to_set

      yield # Continue linting children
    end

    def visit_prop(node)
      # Ignore properties with interpolation
      return if node.name.count > 1 || !node.name.first.is_a?(String)

      nested_properties = node.children.select { |child| child.is_a?(Sass::Tree::PropNode) }
      if nested_properties.any?
        # Treat nested properties specially, as they are a concatenation of the
        # parent with child property
        nested_properties.each do |nested_prop|
          check_property(nested_prop, node.name.join)
        end
      else
        check_property(node)
      end
    end

  private

    def check_property(node, prefix = nil) # rubocop:disable CyclomaticComplexity
      # Ignore properties with interpolation
      return if node.name.count > 1 || !node.name.first.is_a?(String)

      name = prefix ? "#{prefix}-" : ''
      name += node.name.join

      # Ignore vendor-prefixed properties
      return if name.start_with?('-')
      return if (KNOWN_PROPERTIES.include?(name) ||
        @extra_properties.include?(name) ) &&
        !@disabled_properties.include?(name)

      if @disabled_properties.include?(name)
        add_lint(node, "Disabled property #{name}")
      else
        add_lint(node, "Unknown property #{name}")
      end
    end
  end<commit_msg>Fix RuboCop lints for PropertySpelling linter<commit_after>module SCSSLint
  # Checks for misspelled properties.
  class Linter::PropertySpelling < Linter
    include LinterRegistry

    KNOWN_PROPERTIES = File.open(File.join(SCSS_LINT_DATA, 'properties.txt'))
                           .read
                           .split
                           .to_set

    def visit_root(_node)
      @extra_properties = Array(config['extra_properties']).to_set
      @disabled_properties = Array(config['disabled_properties']).to_set

      yield # Continue linting children
    end

    def visit_prop(node)
      # Ignore properties with interpolation
      return if node.name.count > 1 || !node.name.first.is_a?(String)

      nested_properties = node.children.select { |child| child.is_a?(Sass::Tree::PropNode) }
      if nested_properties.any?
        # Treat nested properties specially, as they are a concatenation of the
        # parent with child property
        nested_properties.each do |nested_prop|
          check_property(nested_prop, node.name.join)
        end
      else
        check_property(node)
      end
    end

  private

    def check_property(node, prefix = nil) # rubocop:disable CyclomaticComplexity
      return if contains_interpolation?(node)

      name = prefix ? "#{prefix}-" : ''
      name += node.name.join

      # Ignore vendor-prefixed properties
      return if name.start_with?('-')
      return if known_property?(name) && !@disabled_properties.include?(name)

      if @disabled_properties.include?(name)
        add_lint(node, "Property #{name} is prohibited")
      else
        add_lint(node, "Unknown property #{name}")
      end
    end

    def known_property?(name)
      KNOWN_PROPERTIES.include?(name) || @extra_properties.include?(name)
    end

    def contains_interpolation?(node)
      node.name.count > 1 || !node.name.first.is_a?(String)
    end
  end
{'fraction_non_alphanumeric': 0.09592002161577952, 'fraction_numerical': 0.0010807889759524452, 'mean_word_length': 2.597667638483965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5312855', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1056, 'n_words': 241}