Return violations for resource

 @param [Resource] resource

 @api private
351596
def violations
      validator.rules.each_with_object(Set.new) do |rule, violations|
        violations.merge(rule.violations(resource))
      end
    end
1094443
function normalizeResource(resource) {
    if (!resource) {
      return resource;
    }
    var i = resource.indexOf('/');
    if (i === -1) {
      return resource.toLowerCase();
    }
    return resource.substring(0, i).toLowerCase() + resource.substring(i);
  }
341252
def _diff_violations(self):
        
        if not self._diff_violations_dict:
            self._diff_violations_dict = {
                    src_path: DiffViolations(
                        self._violations.violations(src_path),
                        self._violations.measured_lines(src_path),
                        self._diff.lines_changed(src_path),
                    )
                 for src_path in self._diff.src_paths_changed()
            }
        return self._diff_violations_dict
1326718
public static boolean isValid(Resource resource) {
        return resource instanceof ResourceHandle
                ? ((ResourceHandle) resource).isValid()
                : resource != null && resource.getResourceResolver().getResource(resource.getPath()) != null;
    }
888051
function getActions( state, resource ) {
	var list = state.actionList[ resource.name ] = [];
	_.each( resource.actions, function( action, actionName ) {
		list.push( [ resource.name, actionName ].join( '.' ) );
	} );
}
1136201
def each
      return to_enum unless block_given?
      super do |resource|
        begin
          original, resource.collection = resource.collection, self
          yield resource
        ensure
          resource.collection = original
        end
      end
    end
475300
def check_no_multiple_handlers(self, resource):
        ''''''
        seen = []
        errors = []
        msg = 'HTTP verb "{}" associated to more than one endpoint in "{}".'
        for method in resource.callbacks:
            for op in getattr(method, 'swagger_ops'):
                if op in seen:
                    errors.append(msg.format(op, resource.__name__))
                else:
                    seen.append(op)
        return errors
980653
def check_path_consistency(self, resource):
        ''''''
        msg = ('Method "{}" path variables {}) do not conform with the '
               'resource subpath declaration ({}).')
        errors = []
        # If subpath is not set, it will be detected by another checker
        if resource.subpath is None:
            return errors
        declared = sorted(self.path_params_regex.findall(resource.subpath))
        for callback in resource.callbacks:
            actual = sorted(utils.filter_annotations_by_ptype(
                callback, Ptypes.path))
            if declared == actual:
                continue
            errors.append(msg.format(
                '{}.{}'.format(resource.__name__, callback.__name__),
                actual, resource.subpath))
        return errors
392217
def hrepr_with_resources(self, obj, **cfg):
        
        res = self(obj, **cfg)
        res.resources = self.resources
        return res
691928
def from_api_repr(cls, resource):
        
        version = resource.get("version")
        etag = resource.get("etag")
        policy = cls(etag, version)
        for binding in resource.get("bindings", ()):
            role = binding["role"]
            members = sorted(binding["members"])
            policy[role] = members
        return policy
674875
def requested_by?(resource)
      user = resource.respond_to?(:owner) ? resource.owner : resource
      case
      when current_resource_owner.nil?
        false
      when !user.is_a?(current_resource_owner.class)
        false
      when current_resource_owner.id == user.id
        true
      else
        false
      end
    end
419958
public function getActionsByResource($resource)
    {
        if (!isset($this->resources[$resource])) {
            return null; // no resource found
        }

        $actions = array();
        foreach ($this->resources[$resource] as $action => $path) {
            $actions[] = $action;
        }

        return $actions;
    }
1001460
function getChildResources(resource){
        var result = [], children = _resources[resource].children;
        children.forEach(function (child) {
            var childReturn = getChildResources(child);
            childReturn.push(child);
            result = result.concat(childReturn);
        });

        return result;
    }
778434
def execute
      return :locked if @resource.locked_to_user? @headers

      if @resource.true? options[:overwrite]
        previous_resource_existed = overwrite_destination
      end

      status = super
      return status if %i[precondition_failed conflict].include? status

      @resource.delete_collection

      response_status status, previous_resource_existed
    end
566722
def in_resource(self, field, resource):
        
        resource_field = resource.get(field, None)
        return resource_field is not None and resource_field != ''
693441
def check_required_tags_compliance(self, resource):
        

        missing_tags = []
        notes = []
        resource_tags = {tag.key.lower(): tag.value for tag in resource.tags}

        # Do not audit this resource if it is not in the Account scope
        if resource.resource_type in self.alert_schedule:
            target_accounts = self.alert_schedule[resource.resource_type]['scope']
        else:
            target_accounts = self.alert_schedule['*']['scope']
        if not (resource.account.account_name in target_accounts or '*' in target_accounts):
            return missing_tags, notes

        # Do not audit this resource if the ignore tag was set
        if self.audit_ignore_tag.lower() in resource_tags:
            return missing_tags, notes

        required_tags = list(self.required_tags)

        # Add GDPR tag to required tags if the account must be GDPR compliant
        if self.gdpr_enabled and resource.account.account_name in self.gdpr_accounts:
            required_tags.append(self.gdpr_tag)

        '''
        # Do not audit this resource if it is still in grace period
        if (datetime.utcnow() - resource.resource_creation_date).total_seconds() // 3600 < self.grace_period:
            return missing_tags, notes
        '''

        # Check if the resource is missing required tags or has invalid tag values
        for key in [tag.lower() for tag in required_tags]:
            if key not in resource_tags:
                missing_tags.append(key)
            elif not self.validate_tag(key, resource_tags[key]):
                missing_tags.append(key)
                notes.append('{} tag is not valid'.format(key))

        return missing_tags, notes
305276
def violation_lines(self, src_path):
        

        diff_violations = self._diff_violations().get(src_path)

        if diff_violations is None:
            return []

        return sorted(diff_violations.lines)