fossasia/open-event-orga-server

View on GitHub
app/api/schema/tickets.py

Summary

Maintainability
D
2 days
Test Coverage

Function validate_quantity has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_quantity(self, data):
        if 'max_order' in data and 'min_order' in data:
            if data['max_order'] < data['min_order']:
                raise UnprocessableEntityError(
                    {'pointer': '/data/attributes/max-order'},
Severity: Minor
Found in app/api/schema/tickets.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 validate_discount_code has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_discount_code(self, data, original_data):
        if (
            'relationships' in original_data
            and 'discount-codes' in original_data['data']['relationships']
        ):
Severity: Minor
Found in app/api/schema/tickets.py - About 35 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

Function validate_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_date(self, data, original_data):
        if 'id' in original_data['data']:
            ticket = Ticket.query.filter_by(id=original_data['data']['id']).one()

            if 'sales_starts_at' not in data:
Severity: Minor
Found in app/api/schema/tickets.py - About 25 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

    @validates_schema(pass_original=True)
    def validate_date(self, data, original_data):
        if 'id' in original_data['data']:
            ticket = Ticket.query.filter_by(id=original_data['data']['id']).one()

Severity: Major
Found in app/api/schema/tickets.py and 1 other location - About 1 day to fix
app/api/schema/speakers_calls.py on lines 26..45

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

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 3 locations. Consider refactoring.
Open

        if 'quantity' in data and 'max_order' in data:
            if data['quantity'] < data['max_order']:
                raise UnprocessableEntityError(
                    {'pointer': '/data/attributes/quantity'},
                    "quantity should be greater than or equal to max-order",
Severity: Major
Found in app/api/schema/tickets.py and 2 other locations - About 2 hrs to fix
app/api/schema/tickets.py on lines 52..56
app/api/schema/tickets.py on lines 59..63

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

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 3 locations. Consider refactoring.
Open

        if 'max_order' in data and 'min_order' in data:
            if data['max_order'] < data['min_order']:
                raise UnprocessableEntityError(
                    {'pointer': '/data/attributes/max-order'},
                    "max-order should be greater than or equal to min-order",
Severity: Major
Found in app/api/schema/tickets.py and 2 other locations - About 2 hrs to fix
app/api/schema/tickets.py on lines 59..63
app/api/schema/tickets.py on lines 73..77

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

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 3 locations. Consider refactoring.
Open

        if 'quantity' in data and 'min_order' in data:
            if data['quantity'] < data['min_order']:
                raise UnprocessableEntityError(
                    {'pointer': '/data/attributes/quantity'},
                    "quantity should be greater than or equal to min-order",
Severity: Major
Found in app/api/schema/tickets.py and 2 other locations - About 2 hrs to fix
app/api/schema/tickets.py on lines 52..56
app/api/schema/tickets.py on lines 73..77

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

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 16 locations. Consider refactoring.
Open

    ticket_tags = Relationship(
        attribute='tags',
        self_view='v1.ticket_ticket_tag',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.ticket_tag_list',
Severity: Major
Found in app/api/schema/tickets.py and 15 other locations - About 1 hr to fix
app/api/schema/events.py on lines 169..174
app/api/schema/events.py on lines 179..184
app/api/schema/events.py on lines 189..194
app/api/schema/events.py on lines 199..204
app/api/schema/events.py on lines 217..222
app/api/schema/events.py on lines 244..249
app/api/schema/events.py on lines 254..259
app/api/schema/events.py on lines 296..301
app/api/schema/events.py on lines 397..402
app/api/schema/events.py on lines 407..412
app/api/schema/events.py on lines 433..438
app/api/schema/users.py on lines 117..122
app/api/schema/users.py on lines 136..141
app/api/schema/users.py on lines 180..185
app/api/schema/users.py on lines 298..303

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

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 38 locations. Consider refactoring.
Open

    access_codes = Relationship(
        self_view='v1.ticket_access_code',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.access_code_list',
        related_view_kwargs={'ticket_id': '<id>'},
Severity: Major
Found in app/api/schema/tickets.py and 37 other locations - About 55 mins to fix
app/api/schema/access_codes.py on lines 103..107
app/api/schema/custom_system_roles.py on lines 24..28
app/api/schema/discount_codes.py on lines 128..132
app/api/schema/discount_codes.py on lines 268..272
app/api/schema/events.py on lines 124..128
app/api/schema/events.py on lines 133..137
app/api/schema/events.py on lines 142..146
app/api/schema/events.py on lines 151..155
app/api/schema/events.py on lines 160..164
app/api/schema/events.py on lines 363..367
app/api/schema/events.py on lines 493..497
app/api/schema/events.py on lines 502..506
app/api/schema/faq_types.py on lines 32..36
app/api/schema/groups.py on lines 81..85
app/api/schema/session_types.py on lines 54..58
app/api/schema/sessions.py on lines 161..165
app/api/schema/sessions.py on lines 207..211
app/api/schema/sessions.py on lines 216..220
app/api/schema/speakers.py on lines 83..87
app/api/schema/ticket_tags.py on lines 25..29
app/api/schema/tickets.py on lines 152..156
app/api/schema/tracks.py on lines 54..58
app/api/schema/users.py on lines 108..112
app/api/schema/users.py on lines 127..131
app/api/schema/users.py on lines 162..166
app/api/schema/users.py on lines 171..175
app/api/schema/users.py on lines 190..194
app/api/schema/users.py on lines 199..203
app/api/schema/users.py on lines 217..221
app/api/schema/users.py on lines 226..230
app/api/schema/users.py on lines 235..239
app/api/schema/users.py on lines 244..248
app/api/schema/users.py on lines 253..257
app/api/schema/users.py on lines 262..266
app/api/schema/users.py on lines 271..275
app/api/schema/users.py on lines 280..284
app/api/schema/users.py on lines 289..293

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

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 38 locations. Consider refactoring.
Open

    discount_codes = Relationship(
        self_view='v1.ticket_discount_codes',
        self_view_kwargs={'id': '<id>'},
        related_view='v1.discount_code_list',
        related_view_kwargs={'ticket_id': '<id>'},
Severity: Major
Found in app/api/schema/tickets.py and 37 other locations - About 55 mins to fix
app/api/schema/access_codes.py on lines 103..107
app/api/schema/custom_system_roles.py on lines 24..28
app/api/schema/discount_codes.py on lines 128..132
app/api/schema/discount_codes.py on lines 268..272
app/api/schema/events.py on lines 124..128
app/api/schema/events.py on lines 133..137
app/api/schema/events.py on lines 142..146
app/api/schema/events.py on lines 151..155
app/api/schema/events.py on lines 160..164
app/api/schema/events.py on lines 363..367
app/api/schema/events.py on lines 493..497
app/api/schema/events.py on lines 502..506
app/api/schema/faq_types.py on lines 32..36
app/api/schema/groups.py on lines 81..85
app/api/schema/session_types.py on lines 54..58
app/api/schema/sessions.py on lines 161..165
app/api/schema/sessions.py on lines 207..211
app/api/schema/sessions.py on lines 216..220
app/api/schema/speakers.py on lines 83..87
app/api/schema/ticket_tags.py on lines 25..29
app/api/schema/tickets.py on lines 170..174
app/api/schema/tracks.py on lines 54..58
app/api/schema/users.py on lines 108..112
app/api/schema/users.py on lines 127..131
app/api/schema/users.py on lines 162..166
app/api/schema/users.py on lines 171..175
app/api/schema/users.py on lines 190..194
app/api/schema/users.py on lines 199..203
app/api/schema/users.py on lines 217..221
app/api/schema/users.py on lines 226..230
app/api/schema/users.py on lines 235..239
app/api/schema/users.py on lines 244..248
app/api/schema/users.py on lines 253..257
app/api/schema/users.py on lines 262..266
app/api/schema/users.py on lines 271..275
app/api/schema/users.py on lines 280..284
app/api/schema/users.py on lines 289..293

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

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