----------------------------------------------------------------------------- Rule Definition -----------------------------------------------------------------------------
433404
function create(context) {
    return {
        CallExpression(node) {
            if (isRequireCall(node) && !hasStaticDependencies(node)) {
                context.report(node, message);
            }
        }
    };
}
1190082
function rulename() {
    var ret = this.seq(ALPHA, this.manyf(this.choicef(ALPHA, DIGIT, this.stringf('-'))));
    this.rules.last_def = this.rules.line;
    return [].concat(ret[1]).concat(ret[2]).join('');
}
64438
function setRuleModel (roles, rule, rules, origRule) {
    // allow/deny is last element of rule
    var allow = rule.pop()
    // blanket rule for all models
    if (rule.length === 0) {
        // create role access rule map
        if (!rules.allow) {
            rules.allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.allow[role] = allow
        })
        // break
        return
    }

    // model name is first clause of rule
    var model = rule.shift()
    // create map of models
    if (!rules.model) {
        rules.model = {}
    }
    // create entry for model
    if (!rules.model[model]) {
        rules.model[model] = {}
    }

    // blanket rule for single model
    if (rule.length === 0) {
        // create role access rule map
        if (!rules.model[model].allow) {
            rules.model[model].allow = {}
        }
        // set rule for each role
        _.each(roles, role => {
            rules.model[model].allow[role] = allow
        })
        // break
        return
    }

    // action follows model name
    var action = rule.shift()
    // create map of actions
    if (!rules.model[model].action) {
        rules.model[model].action = {}
    }
    // create entry for action
    if (!rules.model[model].action[action]) {
        rules.model[model].action[action] = {}
    }

    // create action does not have any options
    if (action === 'create') {
        // there should be no more rule clauses
        if (rule.length === 0) {
            // create role access rule map
            if (!rules.model[model].action[action].allow) {
                rules.model[model].action[action].allow = {}
            }
            // set rule for each role
            _.each(roles, role => {
                rules.model[model].action[action].allow[role] = allow
            })
            // break
            return
        }
        else {
            throw new Error('invalid rule '+origRule)
        }
    }
    // all other actions apply to existing model instances and can
    // apply either to any instance or to instances owned by session
    else {
        // if there are two rule clauses then next is a state
        if (rule.length === 2) {
            var state = rule.shift()
            // create map of states
            if (!rules.model[model].action[action].state) {
                rules.model[model].action[action].state = {}
            }
            // create entry for state
            if (!rules.model[model].action[action].state[state]) {
                rules.model[model].action[action].state[state] = {}
            }
            // own/any clause follows state
            rules = rules.model[model].action[action].state[state]
        }
        // otherwise own/any clause follows action
        else {
            rules = rules.model[model].action[action]
        }
        // there must be one additional rule clause
        if (rule.length === 1) {
            var scope = rule.shift()
            // scope must be own or any
            assert.ok(scope === 'own' || scope === 'any', 'invalid rule '+origRule)
            // create map for scope
            if (!rules[scope]) {
                rules[scope] = {}
            }
            // create role access rule map
            if (!rules[scope].allow) {
                rules[scope].allow = {}
            }
            // set rule for each role
            _.each(roles, role => {
                rules[scope].allow[role] = allow
            })
        }
        else {
            throw new Error('invalid rule '+origRule)
        }
    }
}
1101211
function addRules(rules) {
        _.each(rules, function (rule) {
            _global.rules[rule.id] = rule;
        });
    }
635026
public function rules()
    {
        $rules = parent::rules();
        $rules = array_merge($rules, [
            ['fieldTwig', 'string'],
            ['fieldTwig', 'default', 'value' => ''],
            ['columnType', 'string'],
            ['columnType', 'default', 'value' => ''],
            ['decimals', 'number'],
            ['decimals', 'default', 'value' => 0],
            ['textareaRows', 'number'],
            ['textareaRows', 'default', 'value' => 5],
            ['parseBeforeSave', 'boolean'],
            ['parseBeforeSave', 'default', 'value' => false],
            ['parseOnMove', 'boolean'],
            ['parseOnMove', 'default', 'value' => false],
            ['displayType', 'string'],
            ['displayType', 'default', 'value' => 'hidden'],
            ['allowSelect', 'boolean'],
            ['allowSelect', 'default', 'value' => false],
        ]);

        return $rules;
    }
446403
function processRule (rule) {
  pre: {
    if (typeof rule !== 'function' && typeof rule !== 'string') {
      (Array.isArray(rule) && rule[0]) || rule.name, "Validator name must be specified.";
    }
  }
  main: {
    if (typeof rule === 'string') {
      return exports.create(rule);
    }
    else if (typeof rule === 'function') {
      return new exports.Validator({
        validate: rule
      });
    }
    else if (Array.isArray(rule)) {
      return exports.create.apply(exports, rule);
    }
    else {
      return exports.create(rule.name, rule);
    }
  }
  post: {
    __result instanceof exports.Validator;
  }
}
995786
public function addRule($rule, $method = null, $params = [], $message = null)
    {

        // construction des paramètres
        array_unshift($params, $rule, $method);

        call_user_func_array([$this->getValidator(), 'addRule'], $params);

        if (!is_null($message)) {
            if(is_array($message)){
                foreach($message as $rule => $message){
                    $this->getValidator()->addMessage($rule, $message);
                }
            }else{
                $this->getValidator()->addMessage($rule, $message);
            }
        }

        return $this;
    }
984147
public function setRule($rule)
	{
		if(null === $rule)
		{
			$rule = Dispatch::module() . '/' . Dispatch::control() . '/' . Dispatch::action();
		}
		$this->rule = $rule;
	}
139602
def rule(self):
        
        if self._rule:
            return self._rule
        return self._make_rule(member_param=self._member_param,
                               unique_member_param=self._unique_member_param)
393589
public function setupRules()
    {
        parent::setupRules();

        $this->rules->remove('symbol.selector.tag');
        $this->rules->add('symbol.selector.tag', new Rule(new RegexMatcher('/(?>[\s{};]|^)(?=(\w+)[^;}]*\{)/m'), [
            'context' => ['!symbol', '!string', '!number']
        ]));

        $this->rules->add('variable', new Rule(new RegexMatcher('/(\$[\w-]+)/'), ['context' => $this->everywhere()]));
    }
698812
public static void processRuleElement(ParserContext context, ConfigurationRuleBuilder rule, Element element)
    {
        String id = $(element).attr("id");

        List<Element> children = $(element).children().get();
        for (Element child : children)
        {
            Object result = context.processElement(child);

            switch ($(child).tag())
            {
            case "when":
                rule.when(((Condition) result));
                break;

            case "perform":
                rule.perform(((Operation) result));
                break;

            case "otherwise":
                rule.otherwise(((Operation) result));
                break;

            case "where":
                break;
            }
        }

        if (StringUtils.isNotBlank(id))
        {
            rule.withId(id);
        }

    }
104497
private void extractRules(RuleSource ruleSource, Collection<?> blocks, RuleSetBuilder builder) throws RuleException {
        for (Object element : blocks) {
            if (element instanceof AbstractBlock) {
                AbstractBlock block = (AbstractBlock) element;
                if (EXECUTABLE_RULE_TYPES.contains(block.getRole())) {
                    extractExecutableRule(ruleSource, block, builder);
                } else if (GROUP.equals(block.getRole())) {
                    extractGroup(ruleSource, block, builder);
                }
                extractRules(ruleSource, block.getBlocks(), builder);
            } else if (element instanceof Collection<?>) {
                extractRules(ruleSource, (Collection<?>) element, builder);
            }
        }
    }
267851
private function isRule($rule) {

		if(false === is_string($rule)) {
			return false;
		}

		$class = $this -> getRuleClass($rule);

		return true === class_exists($class);
	}
1034183
function setRule (rule, isDefault) {
    // clear id for existing rules
    this.id = undefined
    // if this is default rule then add to list
    if (isDefault) {
        this.defaultRules.push(_.cloneDeep(rule))
    }
    // capture original rule as string for error logging
    var origRule = rule.join(',')
    // require array
    assert.ok(Array.isArray(rule), 'rule array required')
    // get roles array
    var roles = rule
    // get rule string from last element in array
    rule = roles.pop()
    // require rule to be a string
    assert.ok(typeof rule === 'string', 'invalid rule '+origRule)
    // require at least one role
    assert.ok(roles.length, 'one or more roles required '+origRule)
    // split rule on colon to separate into clauses
    var ruleClauses = rule.split(':')
    // first clause must identify type of resource
    var resourceType = ruleClauses.shift()
    // get index of last element in rule
    var lastIdx = ruleClauses.length - 1
    // final element in rule must be 1 or 0 to indicate allow or deny
    var allow = parseInt(ruleClauses[lastIdx])
    // validate
    assert.ok(allow === 0 || allow === 1, 'allow must be 0 or 1 '+origRule)
    // set value to boolean
    ruleClauses[lastIdx] = allow
    // deny rule only allowed on all role
    if (allow === 0) {
        assert.ok(roles.length === 1 && roles[0] === 'all', 'deny can only be set for all role '+origRule)
    }
    // require valid resource type
    assert.ok(resourceTypes[resourceType], 'invalid resource type '+origRule)
    // create entry from resource type if it does not exist
    if (!this.rules[resourceType]) {
        this.rules[resourceType] = {}
    }
    // call type specific method to set rule
    resourceTypes[resourceType](roles, ruleClauses, this.rules[resourceType], origRule)
}
678829
function hasParentRule(rule) {
  if (!rule.parent) {
    return false
  }

  if (rule.parent.type === 'rule') {
    return true
  }

  return hasParentRule(rule.parent)
}
416483
public function setRule($rule, $route)
    {
        $this->rule[$route->getDomain()][$rule][$route->getMethod()] = $route;
    }
1331161
function rule(analyzer) {
	var debug = require('debug');

	analyzer.setMetric('propertyResets');

	analyzer.on('selector', function(rule, selector) {
		var declarations = rule.declarations || [],
			properties;

		// prepare the list of properties used in this selector
		properties = declarations.
		map(function(declaration) {
			return (declaration.type === 'declaration') ? declaration.property : false;
		}).
		filter(function(item) {
			return item !== false;
		});

		debug('%s: %j', selector, properties);

		// iterate through all properties, expand shorthand properties and
		// check if there's no expanded version of it earlier in the array
		properties.forEach(function(property, idx) {
			var expanded;

			// skip if the current property is not the shorthand version
			if (typeof shorthandProperties.shorthandProperties[property] === 'undefined') {
				return;
			}

			// property = 'margin'
			// expanded = [ 'margin-top', 'margin-right', 'margin-bottom', 'margin-left' ]
			expanded = shorthandProperties.expand(property);
			debug('%s: %s', property, expanded.join(', '));

			expanded.forEach(function(expandedProperty) {
				var propertyPos = properties.indexOf(expandedProperty);

				if (propertyPos > -1 && propertyPos < idx) {
					analyzer.incrMetric('propertyResets');
					analyzer.addOffender('propertyResets', format('%s: "%s" resets "%s" property set earlier', selector, property, expandedProperty));
				}
			});
		});
	});
}