open-synergy/opnsynid-hr

View on GitHub
hr_attendance_import_from_machine/wizards/hr_attendance_import.py

Summary

Maintainability
C
1 day
Test Coverage

Function prepare_data has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def prepare_data(self, row, line_num):
        data = {}
        test_error = False

        machine_id = self.attendance_machine_id
Severity: Minor
Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.py - About 4 hrs 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

File hr_attendance_import.py has 288 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).
import base64
import csv
Severity: Minor
Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.py - About 2 hrs to fix

    Function get_name_data has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get_name_data(
    Severity: Minor
    Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.py - About 45 mins to fix

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

          def get_csv_detail(self):
              dict_field = {}
              dict_date = {}
              obj_csv_detail = self.env["hr.attendance_machine_csv_detail"]
      
      
      Severity: Minor
      Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.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

      Function check_sign_in_out has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def check_sign_in_out(self, row, column, line_num, sign_in_code, sign_out_code):
      Severity: Minor
      Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.py - About 35 mins to fix

        Function check_datetime has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def check_datetime(self, row, date_format, time_format, column, line_num):
        Severity: Minor
        Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.py - About 35 mins to fix

          Function button_import has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def button_import(self):
                  self.ensure_one()
          
                  obj_hr_attendance = self.env["hr.attendance"]
          
          
          Severity: Minor
          Found in hr_attendance_import_from_machine/wizards/hr_attendance_import.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

          There are no issues that match your filters.

          Category
          Status