open-synergy/opnsynid-hr

View on GitHub
hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py

Summary

Maintainability
D
3 days
Test Coverage

File hr_overtime_request_batch.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# Copyright 2018 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from datetime import datetime

    Function _compute_policy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _compute_policy(self):
            for batch in self:
                if self.env.user.id == SUPERUSER_ID:
                    batch.confirm_ok = (
                        batch.valid_ok
    Severity: Minor
    Found in hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py - About 45 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

        @api.multi
        @api.depends(
            "state",
            "company_id",
        )
    hr_payslip_workflow_policy/models/hr_payslip.py on lines 11..30

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

    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

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

        state = fields.Selection(
            string="State",
            required=True,
            readonly=True,
            track_visibility="onchange",
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 239..248

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

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

        @api.multi
        def _prepare_confirm_data(self):
            self.ensure_one()
            result = {
                "state": "confirm",
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 340..348
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 350..358
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 360..368
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 241..249
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 251..259
    hr_career_transition/models/hr_career_transition.py on lines 473..481
    hr_career_transition/models/hr_career_transition.py on lines 483..491
    hr_recruitment_request/models/hr_recruitment_request.py on lines 255..263
    hr_recruitment_request/models/hr_recruitment_request.py on lines 265..273
    hr_recruitment_request/models/hr_recruitment_request.py on lines 275..283
    hr_recruitment_request/models/hr_recruitment_request.py on lines 285..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 45.

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

        @api.multi
        def _prepare_valid_data(self):
            self.ensure_one()
            result = {
                "state": "valid",
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 340..348
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 350..358
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 360..368
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 231..239
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 251..259
    hr_career_transition/models/hr_career_transition.py on lines 473..481
    hr_career_transition/models/hr_career_transition.py on lines 483..491
    hr_recruitment_request/models/hr_recruitment_request.py on lines 255..263
    hr_recruitment_request/models/hr_recruitment_request.py on lines 265..273
    hr_recruitment_request/models/hr_recruitment_request.py on lines 275..283
    hr_recruitment_request/models/hr_recruitment_request.py on lines 285..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 45.

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

        @api.multi
        def _prepare_cancel_data(self):
            self.ensure_one()
            result = {
                "state": "cancel",
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 340..348
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 350..358
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 360..368
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 231..239
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 241..249
    hr_career_transition/models/hr_career_transition.py on lines 473..481
    hr_career_transition/models/hr_career_transition.py on lines 483..491
    hr_recruitment_request/models/hr_recruitment_request.py on lines 255..263
    hr_recruitment_request/models/hr_recruitment_request.py on lines 265..273
    hr_recruitment_request/models/hr_recruitment_request.py on lines 275..283
    hr_recruitment_request/models/hr_recruitment_request.py on lines 285..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 45.

    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

        date_start = fields.Datetime(
            string="Date Start",
            required=True,
            default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            readonly=True,
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 60..65

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

    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

        date_end = fields.Datetime(
            string="Date End",
            required=True,
            default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
            readonly=True,
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 53..58

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

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

        @api.multi
        def action_restart(self):
            for overtime in self:
                overtime.write(overtime._prepare_restart())
                overtime.request_ids.action_restart()
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 207..211
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 213..217
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 219..223
    hr_employee_training_evaluation/models/hr_training_participant_evaluation.py on lines 75..79

    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

    Further Reading

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

        @api.multi
        def action_cancel(self):
            for overtime in self:
                overtime.write(overtime._prepare_cancel_data())
                overtime.request_ids.action_cancel()
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 207..211
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 213..217
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 225..229
    hr_employee_training_evaluation/models/hr_training_participant_evaluation.py on lines 75..79

    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

    Further Reading

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

        @api.multi
        def action_valid(self):
            for overtime in self:
                overtime.write(overtime._prepare_valid_data())
                overtime.request_ids.action_valid()
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 207..211
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 219..223
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 225..229
    hr_employee_training_evaluation/models/hr_training_participant_evaluation.py on lines 75..79

    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

    Further Reading

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

        @api.multi
        def action_confirm(self):
            for overtime in self:
                overtime.write(overtime._prepare_confirm_data())
                overtime.request_ids.action_confirm()
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 213..217
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 219..223
    hr_attendance_overtime_request_batch/models/hr_overtime_request_batch.py on lines 225..229
    hr_employee_training_evaluation/models/hr_training_participant_evaluation.py on lines 75..79

    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

    Further Reading

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

        name = fields.Char(
            string="# Batch",
            required=True,
            readonly=True,
            states={"draft": [("readonly", False)]},
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 172..178
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 183..189

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

    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

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

        company_id = fields.Many2one(
            string="Company",
            comodel_name="res.company",
            default=lambda self: self._default_company_id(),
    hr_attendance_overtime_request/models/hr_overtime_request.py on lines 129..132
    hr_payslip_workflow_policy/models/hr_payslip_run.py on lines 15..18

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

    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