Showing 809 of 809 total issues
Function _get_muted_users
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _get_muted_users(self, all_muted, encode_response: bool = False, session=None):
output = dict()
if all_muted is None or len(all_muted) == 0:
return output
- 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 on_update_user_info
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def on_update_user_info(self, activity: Activity) -> (bool, int, str):
if not hasattr(activity, 'object'):
return False, ECodes.MISSING_OBJECT, 'no object on activity'
if not hasattr(activity.object, 'attachments'):
return False, ECodes.MISSING_OBJECT_ATTACHMENTS, 'no attachments on object'
- 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 kick_user
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def kick_user(
self, room_id: Optional[str], user_id: str, reason: str = None, admin_id: str = None, room_name: str = None
) -> None:
# TODO: support get room_id from room name
- 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 set_user_online
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_user_online(self, user_id: str, update_last_online: bool = False) -> None:
@with_session
def _set_user_online(session=None):
user_status = session.query(UserStatus).filter(UserStatus.uuid == user_id).first()
if user_status is 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
Function index
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def index():
form = LoginForm.create()
form.token.data = str(uuid())
if form.validate_on_submit():
# only for the reference implementation, generate a user id and token
- 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 online_counter
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def online_counter():
if len(environ.env.config) == 0 or environ.env.config.get(ConfigKeys.TESTING, False):
return
with GracefulInterruptHandler() as interrupt_handler:
- 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 user_is_on_this_node_ignore_rooms
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def user_is_on_this_node_ignore_rooms(self, activity: Activity) -> bool:
if self.env.node not in {'app', 'wio'}:
return False
namespace = activity.target.url or '/ws'
- 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 _checkUpdatedKeys
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _checkUpdatedKeys() {
var oldCrc32List = JSON.parse(JSON.stringify(_storage.__jstorage_meta.CRC32)),
newCrc32List;
_reloadData();
Function _initEvents
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_initEvents: function() {
var self = this;
// Toggle switch when the switch is clicked
this.button_bg.click(function(e) {
Consider simplifying this complex logical expression. Open
if(
// make the regex if we don't have it already
e=j([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}}
Function msg_insert
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def msg_insert(self, msg_id, from_user, to_user, body, domain, timestamp, channel_id, deleted=False) -> None:
Function update_spam_config
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_spam_config(
Function create_room
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_room(
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, formdata=None, obj=None, prefix='', csrf_context=None,
Function ban_user
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def ban_user(
Function validate_acl_for_action
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def validate_acl_for_action(
Similar blocks of code found in 2 locations. Consider refactoring. Open
def __init__(self):
super(ClearHistoryResource, self).__init__()
self.storage_manager = StorageManager(environ.env)
self.request = request
- 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 38.
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
def __init__(self):
super(KickResource, self).__init__()
self.user_manager = UserManager(environ.env)
self.request = request
- 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 38.
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 get_user_info_attachments_for
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_user_info_attachments_for(user_id: str, encode_attachments: bool=True, include_user_agent: bool=False) -> list:
attachments = list()
for info_key, info_val in environ.env.auth.get_user_info(user_id).items():
attachments.append({
'objectType': info_key,
- 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 room_name_restricted
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def room_name_restricted(room_name: str):
if room_name.strip().lower() in {'admin', 'admins'}:
return True
restricted_room_names = environ.env.db.get_black_list()
- 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"