Validate this rule using the provided ``licensing`` Licensing and yield one error message for each type of error detected.
(self, licensing=None, thorough=False)
| 1911 | } |
| 1912 | |
| 1913 | def validate(self, licensing=None, thorough=False): |
| 1914 | """ |
| 1915 | Validate this rule using the provided ``licensing`` Licensing and yield |
| 1916 | one error message for each type of error detected. |
| 1917 | """ |
| 1918 | is_false_positive = self.is_false_positive |
| 1919 | |
| 1920 | has_license_flags = any(self.license_flags.values()) |
| 1921 | has_many_license_flags = sum(self.license_flags.values()) > 1 |
| 1922 | |
| 1923 | license_expression = self.license_expression |
| 1924 | |
| 1925 | ignorables = ( |
| 1926 | self.ignorable_copyrights, |
| 1927 | self.ignorable_holders, |
| 1928 | self.ignorable_authors, |
| 1929 | self.ignorable_urls, |
| 1930 | self.ignorable_emails, |
| 1931 | ) |
| 1932 | |
| 1933 | if is_false_positive: |
| 1934 | if not self.notes: |
| 1935 | yield 'is_false_positive rule must have notes.' |
| 1936 | |
| 1937 | if self.is_continuous: |
| 1938 | yield 'is_false_positive rule cannot be is_continuous.' |
| 1939 | |
| 1940 | if has_license_flags: |
| 1941 | yield 'is_false_positive rule cannot have is_license_* flags.' |
| 1942 | |
| 1943 | if license_expression: |
| 1944 | yield 'is_false_positive rule cannot have a license_expression.' |
| 1945 | |
| 1946 | if self.has_stored_relevance: |
| 1947 | yield 'is_false_positive rule cannot have a stored relevance.' |
| 1948 | |
| 1949 | if self.referenced_filenames: |
| 1950 | yield 'is_false_positive rule cannot have referenced_filenames.' |
| 1951 | |
| 1952 | if any(ignorables): |
| 1953 | yield 'is_false_positive rule cannot have ignorable_* attributes.' |
| 1954 | |
| 1955 | if self.is_required_phrase: |
| 1956 | yield 'is_false_positive rule cannot be is_required_phase.' |
| 1957 | |
| 1958 | if self.language not in known_languages: |
| 1959 | yield f'Unknown language: {self.language}' |
| 1960 | |
| 1961 | if not is_false_positive: |
| 1962 | if self.relevance == 0 and not self.is_deprecated: |
| 1963 | yield 'Invalid stored relevance. Should be more than 0 for non-deprecated rule' |
| 1964 | |
| 1965 | if not (0 <= self.minimum_coverage <= 100): |
| 1966 | yield 'Invalid rule minimum_coverage. Should be between 0 and 100.' |
| 1967 | |
| 1968 | if not (0 < self.relevance <= 100): |
| 1969 | yield 'Invalid rule relevance. Should be between 0 and 100.' |
| 1970 |
nothing calls this directly
no test coverage detected