Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Codeql (#3084)

Tristan Schulz48ff15a8d3d1
diff --git a/.github/codeql.yml b/.github/codeql.yml
new file mode 100644
index 000000000..2f8e91edd
--- /dev/null
+++ b/.github/codeql.yml
@@ -0,0 +1,17 @@
+query-filters:
+ - exclude:
+ id: py/init-calls-subclass
+ - exclude:
+ id: py/unexpected-raise-in-special-method
+ - exclude:
+ id: py/modification-of-locals
+ - exclude:
+ id: py/multiple-calls-to-init
+ - exclude:
+ id: py/missing-call-to-init
+
+paths:
+ - manim
+paths-ignore:
+ - tests/
+ - example_scenes/
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 000000000..85d892800
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,42 @@
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "main" ]
+ schedule:
+ - cron: "21 16 * * 3"
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ python ]
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ config-file: ./.github/codeql.yml
+ queries: +security-and-quality
+
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
+ with:
+ category: "/language:${{ matrix.language }}"
diff --git a/manim/mobject/graph.py b/manim/mobject/graph.py
index 011def259..d6ce2756a 100644
--- a/manim/mobject/graph.py
+++ b/manim/mobject/graph.py
@@ -627,13 +627,11 @@ class Graph(VMobject, metaclass=ConvertToOpenGL):
f"Vertex identifier '{vertex}' is already used for a vertex in this graph.",
)
- if isinstance(label, (Mobject, OpenGLMobject)):
- label = label
- elif label is True:
+ if label is True:
label = MathTex(vertex, fill_color=label_fill_color)
elif vertex in self._labels:
label = self._labels[vertex]
- else:
+ elif not isinstance(label, (Mobject, OpenGLMobject)):
label = None
base_vertex_config = copy(self.default_vertex_config)
diff --git a/manim/mobject/text/text_mobject.py b/manim/mobject/text/text_mobject.py
index 803d7b435..471e74c13 100644
--- a/manim/mobject/text/text_mobject.py
+++ b/manim/mobject/text/text_mobject.py
@@ -92,7 +92,7 @@ def remove_invisible_chars(mobject: SVGMobject) -> SVGMobject:
:class:`~.SVGMobject`
The SVGMobject without unwanted invisible characters.
"""
-
+ # TODO: Refactor needed
iscode = False
if mobject.__class__.__name__ == "Text":
mobject = mobject[:]
diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py
index 6f53ca91d..346e34974 100644
--- a/manim/mobject/three_d/three_dimensions.py
+++ b/manim/mobject/three_d/three_dimensions.py
@@ -124,12 +124,15 @@ class Surface(VGroup, metaclass=ConvertToOpenGL):
self.pre_function_handle_to_anchor_scale_factor = (
pre_function_handle_to_anchor_scale_factor
)
- self.func = func
+ self._func = func
self._setup_in_uv_space()
self.apply_function(lambda p: func(p[0], p[1]))
if self.should_make_jagged:
self.make_jagged()
+ def func(self, u: float, v: float):
+ return self._func(u, v)
+
def _get_u_values_and_v_values(self):
res = tuplify(self.resolution)
if len(res) == 1:
@@ -371,6 +374,8 @@ class Sphere(Surface):
res_value = (101, 51)
elif config.renderer == RendererType.CAIRO:
res_value = (24, 12)
+ else:
+ raise Exception("Unknown renderer")
resolution = resolution if resolution is not None else res_value