Need to delete any rules that are to be deleted
331750
function updateFormRules(cb) {

    //Filters out any conditional statements that are no longer valid.
    function filterConditionalStatements(rule) {
      return _.filter(rule.ruleConditionalStatements, function(ruleCondStatement) {
        var sourceField = ruleCondStatement.sourceField.toString();

        if (invalidFields[sourceField]) {
          /**
           * If the user flagged the field in this rule for deletion, flag the rule for deletion.
           */
          if (ruleDeletionFlags[sourceField]) {
            rulesFlaggedForDeletion[rule._id.toString()] = true;
          }
          return false;
        } else {
          return true;
        }
      });
    }

    var updatedFieldRules = _.map(form.fieldRules, function(fieldRule) {
      var filteredConditionalStatements = filterConditionalStatements(fieldRule);
      var filteredTargets = _.filter(fieldRule.targetField, function(targetField) {
        if (invalidFields[targetField]) {
          return false;
        } else {
          return true;
        }
      });

      fieldRule.ruleConditionalStatements = filteredConditionalStatements;
      fieldRule.targetField = filteredTargets;
      return fieldRule;
    });

    var updatedPageRules = _.map(form.pageRules, function(pageRule) {
      pageRule.ruleConditionalStatements = filterConditionalStatements(pageRule);
      return pageRule;
    });

    fieldRulesToDelete = _.filter(updatedFieldRules, function(fieldRule) {
      var targetFields = fieldRule.targetField;
      var conditionalStatements = fieldRule.ruleConditionalStatements;
      var fieldRuleId = fieldRule._id.toString();

      return targetFields.length === 0 || conditionalStatements.length === 0 || rulesFlaggedForDeletion[fieldRuleId];
    });

    pageRulesToDelete = _.filter(updatedPageRules, function(pageRule) {
      var conditionalStatements = pageRule.ruleConditionalStatements;
      var pageRuleId = pageRule._id.toString();

      return conditionalStatements.length === 0 || rulesFlaggedForDeletion[pageRuleId];
    });

    fieldRulesToDelete = _.map(fieldRulesToDelete, function(fieldRule) {
      return fieldRule._id.toString();
    });

    pageRulesToDelete = _.map(pageRulesToDelete, function(pageRule) {
      return pageRule._id.toString();
    });

    //Now have all the rules that need to be deleted, these rules need to be removed from the field and page rules
    updatedFieldRules = _.filter(updatedFieldRules, function(updatedFieldRule) {
      return fieldRulesToDelete.indexOf(updatedFieldRule._id.toString()) === -1;
    });


    updatedPageRules = _.filter(updatedPageRules, function(updatedPageRule) {
      return pageRulesToDelete.indexOf(updatedPageRule._id.toString()) === -1;
    });

    form.fieldRules = updatedFieldRules;
    form.pageRules = updatedPageRules;

    form.save(function(err) {
      return cb(err);
    });
  }
1133414
def clear_rules!(forward_to_replicas = false, request_options = {})
      res = clear_rules(forward_to_replicas, request_options)
      wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      return res
    end
288415
def clear_rules_from_all_proxies(self):
        
        self._queue = []        
        if self.debug:
            print 'Clearing rules'
        for service in self.app.get_services():
            for instance in self.app.get_service_instances(service):
                if self.debug:
                    print 'Clearing rules for %s - instance %s' % (service, instance)
                resp = requests.delete("http://{}/gremlin/v1/rules".format(instance))
                if resp.status_code != 200:
                    print 'Failed to clear rules for %s - instance %s' % (service, instance)
522344
def clean(self):
        '''  '''
        if not self.priorDays and not self.startDate:
            raise ValidationError(_(
                'Either a start date or an "up to __ days in the past" limit is required ' +
                'for repeated expense rules that are not associated with a venue or a staff member.'
            ))
        super(GenericRepeatedExpense,self).clean()
883905
function removeProxyRules( ast, session, options ) {

    function isProxyRule( node ) {

        return node.type === "rule" && node.expression.type === "rule_ref";

    }

    const replaceRuleRefs = session.buildVisitor( {

        rule_ref( node, proxy, real ) {

            if ( node.name === proxy ) node.name = real;

        }

    } );

    const allowedStartRules = options.allowedStartRules;
    const rules = [];

    ast.rules.forEach( rule => {

        if ( isProxyRule( rule ) ) {

            replaceRuleRefs( ast, rule.name, rule.expression.name );
            if ( allowedStartRules.indexOf( rule.name ) < 0 ) return;

        }

        rules.push( rule );

    } );

    ast.rules = rules;

}
1270619
function removeThis()
    {
        $workflowParameters = $this->attribute( 'parameter_list' );
        $cleanupList = array();

        $db = eZDB::instance();
        $db->begin();
        if ( isset( $workflowParameters['cleanup_list'] ) && is_array( $workflowParameters['cleanup_list'] ) )
        {
            $cleanupList = $workflowParameters['cleanup_list'];
            foreach ( $cleanupList as $workflowEventID )
            {
                $workflowEvent = eZWorkflowEvent::fetch( $workflowEventID );
                $workflowType = $workflowEvent->eventType();
                $workflowType->cleanup( $this, eZWorkflowEvent::fetch( $workflowEventID ) );
            }
        }
        eZPersistentObject::removeObject( eZWorkflowProcess::definition(), array( 'id' => $this->attribute( 'id' ) ) );
        $db->commit();
    }
1268182
function removeBadFields(attrs){
	var badList = ['scores', 'table', 'headers'];
	for(var k in badList){
		if(attrs[badList[k]])
			delete attrs[badList[k]];
	}
}
1123541
private RuleDto getRuleDto(RuleUpdate change) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      RuleDto rule = dbClient.ruleDao().selectOrFailByKey(dbSession, change.getOrganization(), change.getRuleKey());
      if (RuleStatus.REMOVED == rule.getStatus()) {
        throw new IllegalArgumentException("Rule with REMOVED status cannot be updated: " + change.getRuleKey());
      }
      return rule;
    }
  }
74546
def remove_rules(self, description):
        '''
        
        '''
        rm = []
        description = description.lower()

        for i in range(0, len(self.extract_rules)):
            if self.extract_rules[i]['regex'].search(description):
                rm.append(i)

        for i in rm:
            self.extract_rules.pop(i)

        return len(rm)
870966
function () {
      var sheet = Foundation.stylesheet;

      if (typeof this.rule_idx !== 'undefined') {
        sheet.deleteRule(this.rule_idx);
        sheet.deleteRule(this.rule_idx);
        delete this.rule_idx;
      }
    }
376053
function detachCustomValues(ruleName) {
    ruleName = removeSpace(ruleName);
    var argsRE = /\(\S+\)/g;
    var args = [];
    if(ruleName.match(argsRE)) {
        args = ruleName.match(argsRE)[0].replace(/\(|\)/g, '').split(',');
    }

    return args;
}
34501
public function revokePerms() {
        $conn = ConnectionManager::get('default');
        $stmt = $conn->execute('TRUNCATE TABLE aros_acos');
        $info = $stmt->errorInfo();
        
        if ($info != null && !empty($info)) {
            $this->Flash->success(__("All permissions dropped!"));
        } else {
            $this->Flash->error(__("Error while trying to drop permissions"));
        }
        
        /**
         * Get  Model
         */
        $models = Configure::read('AclManager.aros');
        $mCounter = 0;
        foreach ($models as $model) {
            if($mCounter == (count($models)-1)) {
                $f = $this->{$model}->find('all',
                    ['order' => [$model.'.id' => 'ASC']
                ])->first();

                $this->log($f, LOG_DEBUG);

                $this->Acl->allow([$model => ['id' => $f->id]], 'controllers');
                $this->Flash->success(__("Granted permissions to {0} with id {1}", $model, (int)$f->id));
            }
            $mCounter++;
        }
        
        $this->redirect(array("action" => "permissions"));
    }
50977
static function cleanup()
    {
        $ini = eZINI::instance();
        $db = eZDB::instance();
        $timeFrame = 1;
        if ( $ini->hasVariable( 'TipAFriend', 'TimeFrame' ) )
            $timeFrame = $ini->variable( 'TipAFriend', 'TimeFrame' );
        $time = time() - $timeFrame * 3600;

        $db->query( "DELETE FROM eztipafriend_request
                      WHERE created < $time " );
    }
1354280
def delete(collection_name, spec, safe,
           last_error_args, opts, flags=0):
    
    data = _ZERO_32
    data += bson._make_c_string(collection_name)
    data += struct.pack("<I", flags)
    encoded = bson.BSON.encode(spec, False, opts)
    data += encoded
    if safe:
        (_, remove_message) = __pack_message(2006, data)
        (request_id, error_message, _) = __last_error(collection_name,
                                                      last_error_args)
        return (request_id, remove_message + error_message, len(encoded))
    else:
        (request_id, remove_message) = __pack_message(2006, data)
        return (request_id, remove_message, len(encoded))
470319
protected function beforeDelete() {
	
		$acls = Acl::getAllObjects(array('ruleId' => $this->id));
		foreach ($acls as $acl) {
			$acl->delete();
		}
	
	}
926260
function filterValidRule(rule) {
  return (rule.hasOwnProperty('match')&&typeof rule.match === "object")
  && (rule.hasOwnProperty('use') && (
    typeof rule.use === "object"
    || typeof rule.use === "function"
  ))
  && (
    (rule.match.hasOwnProperty('request'))
    || (rule.match.hasOwnProperty('base'))
  )
}
639560
def delete_tc(self):
        

        rule_finder = TcShapingRuleFinder(logger=logger, tc=self)
        filter_param = rule_finder.find_filter_param()

        if not filter_param:
            message = "shaping rule not found ({}).".format(rule_finder.get_filter_string())
            if rule_finder.is_empty_filter_condition():
                message += " you can delete all of the shaping rules with --all option."
            logger.error(message)

            return 1

        logger.info("delete a shaping rule: {}".format(dict(filter_param)))

        filter_del_command = (
            "{command:s} del dev {dev:s} protocol {protocol:s} "
            "parent {parent:} handle {handle:s} prio {prio:} u32".format(
                command=get_tc_base_command(TcSubCommand.FILTER),
                dev=rule_finder.get_parsed_device(),
                protocol=filter_param.get(Tc.Param.PROTOCOL),
                parent="{:s}:".format(rule_finder.find_parent().split(":")[0]),
                handle=filter_param.get(Tc.Param.FILTER_ID),
                prio=filter_param.get(Tc.Param.PRIORITY),
            )
        )

        result = run_command_helper(
            command=filter_del_command, ignore_error_msg_regexp=None, notice_msg=None
        )

        rule_finder.clear()
        if not rule_finder.is_any_filter():
            logger.debug("there are no filters remain. delete qdiscs.")
            self.delete_all_tc()

        return result