Showing 14 of 14 total issues
File stylers.py
has 632 lines of code (exceeds 250 allowed). Consider refactoring. Open
from PyQt5.QtCore import Qt
from PyQt5 import QtWidgets
import aqt
from anki.stats import CollectionStats
File styles.py
has 370 lines of code (exceeds 250 allowed). Consider refactoring. Open
from .config import ConfigValueGetter
from .internals import css, snake_case, SingletonMetaclass, RequiringMixin
class Style(RequiringMixin, metaclass=SingletonMetaclass):
Function __init__
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def __init__(cls, name, bases, attributes):
super().__init__(name, bases, attributes)
# singleton
cls.instance = None
- 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
File actions_and_settings.py
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
from datetime import datetime
from PyQt5.QtCore import QTimer
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QColorDialog
Similar blocks of code found in 2 locations. Consider refactoring. Open
class InvertImage(Setting, MenuAction):
"""Toggles image inversion.
To learn how images are inverted check also append_to_styles().
"""
- 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 51.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
class InvertLatex(Setting, MenuAction):
"""Toggles latex inversion.
Latex formulas are nothing more than images with class "latex".
To learn how formulas are inverted check also append_to_styles().
- 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 51.
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
Function init_ui
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def init_ui(self, title):
self.setWindowTitle(title)
btn_close = create_button('Close', self.close)
Function refresh
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def refresh(self, reload=False):
"""
Refresh display by re-enabling night or normal mode,
regenerate customizable css strings.
"""
- 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_action
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_action(self, name, text, callback, checkable=False, shortcut=None):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, parent, color=None, on_color_change=None, name='Color', verify_colors=False):
Function init
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def init(self, editor, mw, widget, parentWindow, addMode=False):
Function _addButton
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _addButton(self, editor, icon, command, *args, **kwargs):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, parent, disabled_stylers: set, all_stylers, title=_('Choose what to style'), on_update=None):
Function move_args_to_kwargs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def move_args_to_kwargs(original_function, args, kwargs):
args = list(args)
import inspect
- 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"