Showing 17 of 73 total issues
Identical blocks of code found in 2 locations. Consider refactoring. Open
theme: {
extend: {
colors: {
primary: {
50: "#f0f9ff",
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 201.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
theme: {
extend: {
colors: {
primary: {
50: "#f0f9ff",
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 201.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File configurator.py
has 499 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
The configurator registers routes in a FastAPI application while
adding support for dependency injection during the configuration phase.
FastAPI does not provide any built-in support for dependency injection
Function from_payload
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def from_payload(
cls, prefix: str, pydantic_type: type[T], data: Mapping[str, Any]
) -> "FormModel[T]":
try:
return cls(prefix, pydantic_type(**data.get(prefix, {})), {}, True)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function unflatten_struct
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def unflatten_struct(
flatten_input: Mapping[str, Any],
unflattened_output: MutableMapping[str, Any] | MutableSequence[Any],
level: int = 0,
*,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, client: "WebTestClient", origin: str, form: "Element"):
self._client = client
self._form = form
self._origin = origin
self._formfields: dict[str, Element] = {}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generate_docstring
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def generate_docstring(
func_def: ast.FunctionDef, component_name: str, add_content: bool
) -> str:
"""Generate a docstring for a JinjaX component."""
# Extract function name and docstring
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function run
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def run(self) -> list[nodes.Node]:
"""Generate structured and styled documentation for the directive."""
container_node = nodes.container(classes=["jinjax-component"])
# Extract the signature (first line of arguments)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function iter_all_by_text
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def iter_all_by_text(
self, text: str, *, node_name: str | None = None
) -> "Iterator[Element]":
"""Return an iterator of all elements that match the text."""
nodes = self._tag.find_all(string=re.compile(rf"\s*{text}\s*"))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function as_def
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def as_def(self) -> ast.FunctionDef:
"""Return the component definition as a python function definition."""
signature = "def component(): pass"
match = RX_META_HEADER.match(self.source)
if match:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create_ref_node
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def create_ref_node(arg_type: str) -> nodes.Node:
"""
Creates a cross-reference node if a type has been inferred.
At the monent, type inferred are types containing a `.`, otherwise
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_widget
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_widget(
Avoid deeply nested control flow statements. Open
if is_union(typ):
args = typ.__args__
for arg in args:
if arg.__name__ == part:
typ = arg
Avoid deeply nested control flow statements. Open
if "selected" in option.attrs:
self._formdata[fieldname] = option.attrs.get(
"value", option.text
)
break
Function unflatten_struct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def unflatten_struct(
Function post
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def post(