<commit_before># frozen_string_literal: true

class Setup::RulesController < PrivateController
  helper_method :rule
  attr_reader :rule

  def new
    reasons = reasons_rule_can_not_be_added(kind)
    if reasons.any?
      flash[:alert] = "Sorry, #{reasons.first}"
      redirect_to(root_path)
      return
    end

    @rule = current_package.rules.build(kind: kind)
    @rule.formulas.build(rule: @rule)
  end

  def edit
    @rule = current_package.rules.find(params[:id])<commit_msg>Add a default name to rules make creation easier<commit_after># frozen_string_literal: true

class Setup::RulesController < PrivateController
  helper_method :rule
  attr_reader :rule

  def new
    reasons = reasons_rule_can_not_be_added(kind)
    if reasons.any?
      flash[:alert] = "Sorry, #{reasons.first}"
      redirect_to(root_path)
      return
    end

    @rule = current_package.rules.build(kind: kind, name: "#{current_package.name} - #{kind}" )
    @rule.formulas.build(rule: @rule)
  end

  def edit
    @rule = current_package.rules.find(params[:id])
{'fraction_non_alphanumeric': 0.1080568720379147, 'fraction_numerical': 0.0, 'mean_word_length': 3.888888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2221799', 'n_tokens_mistral': 344, 'n_tokens_neox': 339, 'n_words': 74}