WeblateOrg / weblate

Function with cyclomatic complexity higher than threshold PY-R1000
Anti-pattern
Minor
a month ago8 months old
PluralTextarea.render has a cyclomatic complexity of 16 with "high" risk
 269
 270        return result
 271
 272    def render(self, name, value, attrs=None, renderer=None, **kwargs): 273        """Render all textareas with correct plural labels."""
 274        unit = value
 275        values = unit.get_target_plurals()
Change.get_details_display has a cyclomatic complexity of 30 with "very-high" risk
778            or self.action in self.ACTIONS_REVERTABLE
779        )
780
781    def get_details_display(self):  # noqa: C901782        from weblate.addons.models import ADDONS
783        from weblate.utils.markdown import render_markdown
784
TranslationStats._calculate_basic has a cyclomatic complexity of 67 with "critical" risk
 500    def has_review(self):
 501        return self._object.enable_review
 502
 503    def _calculate_basic(self) -> None:  # noqa: PLR0914 504        values = (
 505            "state",
 506            "num_words",
AggregatingStats._calculate_basic has a cyclomatic complexity of 16 with "high" risk
 836    def calculate_source(self, stats: dict, all_stats: list) -> None:
 837        return
 838
 839    def _calculate_basic(self) -> None: 840        stats = zero_stats(self.basic_keys)
 841        all_stats = [
 842            obj.stats
Unit.save has a cyclomatic complexity of 16 with "high" risk
 443            name = source
 444        return f"{self.pk}: {name}"
 445
 446    def save( 447        self,
 448        *,
 449        same_content: bool = False,