Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/adapt tests for warning #70

Merged
merged 23 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions schemas/package_common.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
ct2034 marked this conversation as resolved.
Show resolved Hide resolved
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="VersionType">
<xs:annotation>
<xs:documentation>
The version number must have the form "X.Y.Z" where X, Y, and Z
are non-negative integers, and must not contain leading zeroes.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="(0|[1-9][0-9]*)(.(0|[1-9][0-9]*)){2}"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="DescriptionType" mixed="true">
<xs:annotation>
<xs:documentation>
The description allows any content but should be limited to XHTML.
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:simpleType name="EmailType">
<xs:annotation>
<xs:documentation>
A valid email address must follow several complex rules
(see https://en.wikipedia.org/wiki/Email_address).
For ROS packages only a few are enforced, and not the full character set
is supported.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="[-a-zA-Z0-9_%+]+(\.[-a-zA-Z0-9_%+]+)*@[-a-zA-Z0-9%]+(\.[-a-zA-Z0-9%]+)*\.[a-zA-Z]{2,}"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="PersonWithEmailType">
<xs:simpleContent>
<xs:extension base="xs:token">
<xs:attribute name="email" type="EmailType" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="PersonWithOptionalEmailType">
<xs:simpleContent>
<xs:extension base="xs:token">
<xs:attribute name="email" type="EmailType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:simpleType name="UrlTypeEnum">
<xs:restriction base="xs:token">
<xs:enumeration value="website"/>
<xs:enumeration value="bugtracker"/>
<xs:enumeration value="repository"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="UrlType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="type" type="UrlTypeEnum" use="optional" default="website"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:simpleType name="VersionLimitType">
<xs:annotation>
<xs:documentation>
The version limit must have the form "X.Y.Z", "X.Y", or "X".
See documentation for VersionType for further details.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="(0|[1-9][0-9]*)(.(0|[1-9][0-9]*)){0,2}"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="ExportType">
<xs:sequence>
<xs:any processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
69 changes: 69 additions & 0 deletions schemas/package_format1.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="package_common.xsd"/>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less than the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less than or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater than or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater than the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="package">
<xs:annotation>
<xs:documentation>
Specified in REP 127 (see http://www.ros.org/reps/rep-0127.html).
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>
The package name should be unique within the ROS community.
It may differ from the folder name into which it is checked out,
but that is not recommended.
It must start with a lower-case letter and consist of only
lower-case letters, numbers and underscores.
It must not have two consecutive underscores.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[a-z](_?[a-z0-9]+)*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="version" type="VersionType" minOccurs="1" maxOccurs="1"/>
<xs:element name="description" type="DescriptionType" minOccurs="1" maxOccurs="1"/>
<xs:element name="maintainer" type="PersonWithEmailType" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="license" type="xs:token" minOccurs="1" maxOccurs="unbounded"/>

<xs:element name="url" type="UrlType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="author" type="PersonWithOptionalEmailType" minOccurs="0" maxOccurs="unbounded"/>

<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="DependencyType" name="build_depend"/>
<xs:element type="DependencyType" name="buildtool_depend"/>
<xs:element type="DependencyType" name="run_depend"/>
<xs:element type="DependencyType" name="test_depend"/>
<xs:element type="DependencyType" name="conflict"/>
<xs:element type="DependencyType" name="replace"/>
</xs:choice>

<xs:element name="export" type="ExportType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="format" fixed="1" use="optional"/>
</xs:complexType>
</xs:element>
</xs:schema>
73 changes: 73 additions & 0 deletions schemas/package_format2.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="package_common.xsd"/>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less than the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less than or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater than or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater than the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="package">
<xs:annotation>
<xs:documentation>
Specified in REP 140 (see http://www.ros.org/reps/rep-0140.html).
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>
The package name should be unique within the ROS community.
It may differ from the folder name into which it is checked out,
but that is not recommended.
It must start with a lower-case letter and consist of only
lower-case letters, numbers and underscores.
It must not have two consecutive underscores.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[a-z](_?[a-z0-9]+)*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="version" type="VersionType" minOccurs="1" maxOccurs="1"/>
<xs:element name="description" type="DescriptionType" minOccurs="1" maxOccurs="1"/>
<xs:element name="maintainer" type="PersonWithEmailType" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="license" type="xs:token" minOccurs="1" maxOccurs="unbounded"/>

<xs:element name="url" type="UrlType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="author" type="PersonWithOptionalEmailType" minOccurs="0" maxOccurs="unbounded"/>

<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="DependencyType" name="build_depend"/>
<xs:element type="DependencyType" name="build_export_depend"/>
<xs:element type="DependencyType" name="buildtool_depend"/>
<xs:element type="DependencyType" name="buildtool_export_depend"/>
<xs:element type="DependencyType" name="exec_depend"/>
<xs:element type="DependencyType" name="depend"/>
<xs:element type="DependencyType" name="doc_depend"/>
<xs:element type="DependencyType" name="test_depend"/>
<xs:element type="DependencyType" name="conflict"/>
<xs:element type="DependencyType" name="replace"/>
</xs:choice>

<xs:element name="export" type="ExportType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="format" fixed="2" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
113 changes: 113 additions & 0 deletions schemas/package_format3.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="package_common.xsd"/>

<xs:complexType name="ConditionalType">
<xs:simpleContent>
<xs:extension base="xs:token">
<xs:attribute name="condition" use="optional">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[$A-Za-z0-9_\s&lt;&gt;!=()-]*"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="DependencyType">
<xs:simpleContent>
<xs:extension base="xs:token">
<!-- The dependency must have a version less than the specified limit. -->
<xs:attribute name="version_lt" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version less than or equal to the specified limit. -->
<xs:attribute name="version_lte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version equal to the specified limit. -->
<xs:attribute name="version_eq" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater than or equal to the specified limit. -->
<xs:attribute name="version_gte" type="VersionLimitType" use="optional"/>
<!-- The dependency must have a version greater than the specified limit. -->
<xs:attribute name="version_gt" type="VersionLimitType" use="optional"/>
<xs:attribute name="condition" use="optional">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[$A-Za-z0-9_\s&quot;'&lt;&gt;!=()-]*"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="LicenseType">
<xs:simpleContent>
<xs:extension base="xs:token">
<xs:attribute name="file" type="xs:token" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:complexType name="VersionWithOptionalCompatibilityType">
<xs:simpleContent>
<xs:extension base="VersionType">
<xs:attribute name="compatibility" type="VersionLimitType" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

<xs:element name="package">
<xs:annotation>
<xs:documentation>
Specified in REP 149 (see http://www.ros.org/reps/rep-0149.html).
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>
The package name should be unique within the ROS community.
It may differ from the folder name into which it is checked out,
but that is not recommended.
It must start with a lower-case letter and consist of only
lower-case letters, numbers and underscores.
It must not have two consecutive underscores.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:pattern value="[a-z](_?[a-z0-9]+)*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="version" type="VersionType" minOccurs="1" maxOccurs="1"/>
<xs:element name="description" type="DescriptionType" minOccurs="1" maxOccurs="1"/>
<xs:element name="maintainer" type="PersonWithEmailType" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="license" type="LicenseType" minOccurs="1" maxOccurs="unbounded"/>

<xs:element name="url" type="UrlType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="author" type="PersonWithOptionalEmailType" minOccurs="0" maxOccurs="unbounded"/>

<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element type="DependencyType" name="build_depend"/>
<xs:element type="DependencyType" name="build_export_depend"/>
<xs:element type="DependencyType" name="buildtool_depend"/>
<xs:element type="DependencyType" name="buildtool_export_depend"/>
<xs:element type="DependencyType" name="exec_depend"/>
<xs:element type="DependencyType" name="depend"/>
<xs:element type="DependencyType" name="doc_depend"/>
<xs:element type="DependencyType" name="test_depend"/>
<xs:element type="DependencyType" name="conflict"/>
<xs:element type="DependencyType" name="replace"/>
</xs:choice>

<xs:element name="group_depend" type="ConditionalType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="member_of_group" type="ConditionalType" minOccurs="0" maxOccurs="unbounded"/>

<xs:element name="export" type="ExportType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
<xs:attribute name="format" fixed="3" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
1 change: 1 addition & 0 deletions src/ros_license_toolkit/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

"""This module contains the checks for the linter."""


ant-u marked this conversation as resolved.
Show resolved Hide resolved
from enum import IntEnum

from ros_license_toolkit.package import Package, PackageException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LicensesInCodeCheck(Check):

def __init__(self: 'LicensesInCodeCheck'):
Check.__init__(self)
# self.package_xml_vers = package_xml_version
ant-u marked this conversation as resolved.
Show resolved Hide resolved
self.declared_licenses: Dict[str, LicenseTag] = {}
self.files_with_uncovered_licenses: Dict[str, List[str]] = {}
self.files_not_matched_by_any_license_tag: Dict[str, List[str]] = {}
Expand Down
Loading