fossasia/open-event-orga-server

View on GitHub
app/api/custom/check_in_stats.py

Summary

Maintainability
F
3 days
Test Coverage

File check_in_stats.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import datetime

from flask import Blueprint, request
from sqlalchemy import desc

Severity: Minor
Found in app/api/custom/check_in_stats.py - About 2 hrs to fix

Function get_session_stats has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_session_stats(session_ids, session_checked_in, session_checked_out):
    """
    Get session stats
    @param session_ids: session id to get
    @param session_checked_in: session_checked_in
Severity: Minor
Found in app/api/custom/check_in_stats.py - About 1 hr to fix

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_track_stats has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def get_track_stats(track_ids, check_in_attendee, check_out_attendee, current_time):
    """
    get track stats
    @param track_ids: track_ids
    @param check_in_attendee: check_in_attendee
Severity: Minor
Found in app/api/custom/check_in_stats.py - About 55 mins to fix

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        track_checked_out = db.session.query(UserCheckIn, Session).filter(
            Session.id.in_(
                [user_check_in.session_id for user_check_in in check_out_attendee]
            ),
            UserCheckIn.id.in_(
Severity: Major
Found in app/api/custom/check_in_stats.py and 1 other location - About 5 hrs to fix
app/api/custom/check_in_stats.py on lines 228..235

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 86.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        track_checked_in = db.session.query(UserCheckIn, Session).filter(
            Session.id.in_(
                [user_check_in.session_id for user_check_in in check_in_attendee]
            ),
            UserCheckIn.id.in_([user_check_in.id for user_check_in in check_in_attendee]),
Severity: Major
Found in app/api/custom/check_in_stats.py and 1 other location - About 5 hrs to fix
app/api/custom/check_in_stats.py on lines 244..253

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 86.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    track_checked_out = db.session.query(UserCheckIn, Session).filter(
        Session.id.in_(
            [user_check_in.session_id for user_check_in in session_checked_out]
        ),
        UserCheckIn.station_id.in_(check_out_stations),
Severity: Major
Found in app/api/custom/check_in_stats.py and 1 other location - About 3 hrs to fix
app/api/custom/check_in_stats.py on lines 85..91

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 67.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    track_checked_in = db.session.query(UserCheckIn, Session).filter(
        Session.id.in_(
            [user_check_in.session_id for user_check_in in session_checked_in]
        ),
        UserCheckIn.station_id.in_(check_in_stations),
Severity: Major
Found in app/api/custom/check_in_stats.py and 1 other location - About 3 hrs to fix
app/api/custom/check_in_stats.py on lines 100..106

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 67.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        current_session = (
            db.session.query(Session, SessionType)
            .filter(Session.id == session_id, Session.session_type_id == SessionType.id)
            .with_entities(SessionType.name)
Severity: Major
Found in app/api/custom/check_in_stats.py and 1 other location - About 2 hrs to fix
app/api/custom/check_in_stats.py on lines 172..175

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        current_track = (
            db.session.query(Session, Track)
            .filter(Session.id == session_id, Session.track_id == Track.id)
            .with_entities(Track.name)
Severity: Major
Found in app/api/custom/check_in_stats.py and 1 other location - About 2 hrs to fix
app/api/custom/check_in_stats.py on lines 163..166

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

Further Reading

There are no issues that match your filters.

Category
Status