diff --git a/coldfront/core/allocation/tasks.py b/coldfront/core/allocation/tasks.py index 883420aee0..dedd2e2d89 100644 --- a/coldfront/core/allocation/tasks.py +++ b/coldfront/core/allocation/tasks.py @@ -85,7 +85,7 @@ def send_eula_reminders(): logger.debug(f"Allocation(s) EULA reminder sent to users {email_receiver_list}.") -def send_expiry_emails(): +def send_expiry_emails(): # noqa: C901 # FIXME: function is too complex # Allocations expiring soon for user in User.objects.all(): projectdict = {} diff --git a/coldfront/core/allocation/views.py b/coldfront/core/allocation/views.py index 02c129d267..1fe4c5f350 100644 --- a/coldfront/core/allocation/views.py +++ b/coldfront/core/allocation/views.py @@ -208,7 +208,7 @@ def get(self, request, *args, **kwargs): context["allocation"] = allocation_obj return self.render_to_response(context) - def post(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex pk = self.kwargs.get("pk") allocation_obj = get_object_or_404(Allocation, pk=pk) allocation_users = allocation_obj.allocationuser_set.exclude(status__name__in=["Removed"]).order_by( @@ -434,7 +434,7 @@ class AllocationListView(LoginRequiredMixin, ListView): context_object_name = "allocation_list" paginate_by = 25 - def get_queryset(self): + def get_queryset(self): # noqa: C901 # FIXME: method is too complex order_by = self.request.GET.get("order_by") if order_by: direction = self.request.GET.get("direction") @@ -659,7 +659,7 @@ def get_form(self, form_class=None): form_class = self.get_form_class() return form_class(self.request.user, self.kwargs.get("project_pk"), **self.get_form_kwargs()) - def form_valid(self, form): + def form_valid(self, form): # noqa: C901 # FIXME: method is too complex form_data = form.cleaned_data project_obj = get_object_or_404(Project, pk=self.kwargs.get("project_pk")) resource_obj = form_data.get("resource") @@ -1762,7 +1762,7 @@ def get(self, request, *args, **kwargs): context["note_form"] = note_form return render(request, self.template_name, context) - def post(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex pk = self.kwargs.get("pk") if not self.request.user.is_superuser: messages.error(request, "You do not have permission to update an allocation change request") @@ -2028,7 +2028,7 @@ def get(self, request, *args, **kwargs): context["attributes"] = allocation_attributes_to_change return render(request, self.template_name, context) - def post(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex change_requested = False attribute_changes_to_make = set({}) diff --git a/coldfront/core/attribute_expansion.py b/coldfront/core/attribute_expansion.py index 68260536f2..88fbef9297 100644 --- a/coldfront/core/attribute_expansion.py +++ b/coldfront/core/attribute_expansion.py @@ -67,7 +67,7 @@ def get_attriblist_str(attribute_name, resources=[], allocations=[]): return attriblist -def get_attribute_parameter_value(argument, attribute_parameter_dict, error_text, resources=[], allocations=[]): +def get_attribute_parameter_value(argument, attribute_parameter_dict, error_text, resources=[], allocations=[]): # noqa: C901 # FIXME: function is too complex """Evaluates the argument for a attribute parameter statement. This is called by process_attribute_parameter_string and handles @@ -178,7 +178,7 @@ def get_attribute_parameter_value(argument, attribute_parameter_dict, error_text return None -def process_attribute_parameter_operation(opcode, oldvalue, argument, error_text): +def process_attribute_parameter_operation(opcode, oldvalue, argument, error_text): # noqa: C901 # FIXME: method is too complex """Process the specified operation for attribute_parameter_dict. This is called by process_attribute_parameter_string and handles diff --git a/coldfront/core/project/views.py b/coldfront/core/project/views.py index df2adc82f3..3e9b8f6d5d 100644 --- a/coldfront/core/project/views.py +++ b/coldfront/core/project/views.py @@ -108,7 +108,7 @@ def test_func(self): messages.error(self.request, "You do not have permission to view the previous page.") return False - def get_context_data(self, **kwargs): + def get_context_data(self, **kwargs): # noqa: C901 # FIXME: method is too complex context = super().get_context_data(**kwargs) # Can the user update the project? if self.request.user.is_superuser: @@ -800,7 +800,7 @@ def dispatch(self, request, *args, **kwargs): else: return super().dispatch(request, *args, **kwargs) - def post(self, request, *args, **kwargs): + def post(self, request, *args, **kwargs): # noqa: C901 # FIXME: method is too complex user_search_string = request.POST.get("q") search_by = request.POST.get("search_by") pk = self.kwargs.get("pk") diff --git a/coldfront/core/resource/views.py b/coldfront/core/resource/views.py index 7f9e4aca3a..39df346031 100644 --- a/coldfront/core/resource/views.py +++ b/coldfront/core/resource/views.py @@ -199,7 +199,7 @@ class ResourceListView(LoginRequiredMixin, ListView): context_object_name = "resource_list" paginate_by = 25 - def get_queryset(self): + def get_queryset(self): # noqa: C901 # FIXME: method is too complex order_by = self.request.GET.get("order_by", "id") direction = self.request.GET.get("direction", "asc") if order_by != "name": diff --git a/coldfront/plugins/auto_compute_allocation/tasks.py b/coldfront/plugins/auto_compute_allocation/tasks.py index 03a789d3e0..f43d689fe2 100644 --- a/coldfront/plugins/auto_compute_allocation/tasks.py +++ b/coldfront/plugins/auto_compute_allocation/tasks.py @@ -25,7 +25,7 @@ # automatically create a compute allocation, called by project_new signal -def add_auto_compute_allocation(project_obj): +def add_auto_compute_allocation(project_obj): # noqa: C901 # FIXME: method is too complex """Method to add a compute allocation automatically upon project creation - uses signals for project creation""" # if project_code not enabled or None or empty, print appropriate message and stop diff --git a/coldfront/plugins/freeipa/management/commands/freeipa_check.py b/coldfront/plugins/freeipa/management/commands/freeipa_check.py index 165b033127..a55040e9b9 100644 --- a/coldfront/plugins/freeipa/management/commands/freeipa_check.py +++ b/coldfront/plugins/freeipa/management/commands/freeipa_check.py @@ -186,7 +186,7 @@ def check_user_freeipa(self, user, active_groups, removed_groups): logger.info("User %s should be removed from freeipa group: %s", user.username, g) self.remove_group(user, g, freeipa_status) - def process_user(self, user): + def process_user(self, user): # noqa: C901 # FIXME: method is too complex if self.filter_user and self.filter_user != user.username: return @@ -241,7 +241,7 @@ def process_user(self, user): self.check_user_freeipa(user, active_groups, removed_groups) - def handle(self, *args, **options): + def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex os.environ["KRB5_CLIENT_KTNAME"] = CLIENT_KTNAME verbosity = int(options["verbosity"]) diff --git a/coldfront/plugins/freeipa/management/commands/freeipa_expire_users.py b/coldfront/plugins/freeipa/management/commands/freeipa_expire_users.py index 3bd0bcdd09..5be72228dc 100644 --- a/coldfront/plugins/freeipa/management/commands/freeipa_expire_users.py +++ b/coldfront/plugins/freeipa/management/commands/freeipa_expire_users.py @@ -35,7 +35,7 @@ def writerow(self, row): os.dup2(devnull, sys.stdout.fileno()) sys.exit(1) - def handle(self, *args, **options): + def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex os.environ["KRB5_CLIENT_KTNAME"] = CLIENT_KTNAME verbosity = int(options["verbosity"]) diff --git a/coldfront/plugins/freeipa/tasks.py b/coldfront/plugins/freeipa/tasks.py index ad85cd06a3..7de19a3a4a 100644 --- a/coldfront/plugins/freeipa/tasks.py +++ b/coldfront/plugins/freeipa/tasks.py @@ -59,7 +59,7 @@ def add_user_group(allocation_user_pk): logger.info("Added user %s to group %s successfully", allocation_user.user.username, g) -def remove_user_group(allocation_user_pk): +def remove_user_group(allocation_user_pk): # noqa: C901 # FIXME: function is too complex allocation_user = AllocationUser.objects.get(pk=allocation_user_pk) if allocation_user.allocation.status.name not in [ "Active", diff --git a/coldfront/plugins/project_openldap/management/commands/project_openldap_sync.py b/coldfront/plugins/project_openldap/management/commands/project_openldap_sync.py index ef2d83e026..1f72482941 100644 --- a/coldfront/plugins/project_openldap/management/commands/project_openldap_sync.py +++ b/coldfront/plugins/project_openldap/management/commands/project_openldap_sync.py @@ -232,7 +232,7 @@ def handle_project_removal_if_needed(self, project, project_ou_dn, sync=False): f"Exception removing {project.project_code}, DN: {project_ou_dn} in OpenLDAP: {e}" ) - def handle_description_update( + def handle_description_update( # noqa: C901 # FIXME: method is too complex self, project, project_dn="", @@ -299,7 +299,7 @@ def local_get_openldap_members(self, dn): members.extend(entry.memberUid.values) return tuple(members) - def sync_members( + def sync_members( # noqa: C901 # FIXME: method is too complex self, project, cf_members, @@ -400,7 +400,7 @@ def sync_members( ) # N.B. this is the main function to check projects... - def sync_check_project( + def sync_check_project( # noqa: C901 # FIXME: method is too complex self, project_group, sync=False, @@ -619,7 +619,7 @@ def loop_all_projects( # -------------------------------- - def handle(self, *args, **options): + def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex verbosity = int(options["verbosity"]) root_logger = logging.getLogger("") if verbosity == 0: diff --git a/coldfront/plugins/slurm/associations.py b/coldfront/plugins/slurm/associations.py index 28b74fde92..406ceef194 100644 --- a/coldfront/plugins/slurm/associations.py +++ b/coldfront/plugins/slurm/associations.py @@ -65,7 +65,7 @@ def __init__(self, name, specs=None): self.accounts = {} @staticmethod - def new_from_stream(stream): + def new_from_stream(stream): # noqa: C901 # FIXME: method is too complex """Create a new SlurmCluster by parsing the output from sacctmgr dump.""" cluster = None parent = None diff --git a/coldfront/plugins/slurm/management/commands/slurm_check.py b/coldfront/plugins/slurm/management/commands/slurm_check.py index ded64a6ce5..c7d273bafb 100644 --- a/coldfront/plugins/slurm/management/commands/slurm_check.py +++ b/coldfront/plugins/slurm/management/commands/slurm_check.py @@ -242,7 +242,7 @@ def _cluster_from_dump(self, cluster): return slurm_cluster - def handle(self, *args, **options): + def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex verbosity = int(options["verbosity"]) root_logger = logging.getLogger("") if verbosity == 0: diff --git a/coldfront/plugins/xdmod/management/commands/xdmod_usage.py b/coldfront/plugins/xdmod/management/commands/xdmod_usage.py index dfdb38ab6f..a5f0b38e46 100644 --- a/coldfront/plugins/xdmod/management/commands/xdmod_usage.py +++ b/coldfront/plugins/xdmod/management/commands/xdmod_usage.py @@ -51,7 +51,7 @@ def write(self, data): os.dup2(devnull, sys.stdout.fileno()) sys.exit(1) - def process_total_storage(self): + def process_total_storage(self): # noqa: C901 # FIXME: method is too complex header = [ "allocation_id", "pi", @@ -156,7 +156,7 @@ def process_total_storage(self): ) ) - def process_total_gpu_hours(self): + def process_total_gpu_hours(self): # noqa: C901 # FIXME: method is too complex header = [ "allocation_id", "pi", @@ -261,7 +261,7 @@ def process_total_gpu_hours(self): ) ) - def process_total_cpu_hours(self): + def process_total_cpu_hours(self): # noqa: C901 # FIXME: method is too complex header = [ "allocation_id", "pi", @@ -359,7 +359,7 @@ def process_total_cpu_hours(self): ) ) - def process_cloud_core_time(self): + def process_cloud_core_time(self): # noqa: C901 # FIXME: method is too complex header = [ "allocation_id", "pi", @@ -457,7 +457,7 @@ def process_cloud_core_time(self): ) ) - def handle(self, *args, **options): + def handle(self, *args, **options): # noqa: C901 # FIXME: method is too complex verbosity = int(options["verbosity"]) root_logger = logging.getLogger("") if verbosity == 0: diff --git a/pyproject.toml b/pyproject.toml index 33bf9873f8..8ee2f1cf6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,7 +107,10 @@ indent-width = 4 target-version = "py312" [tool.ruff.lint] -select = ["E4", "E7", "E9", "F", "I"] +select = ["E4", "E7", "E9", "F", "I", "C90"] + +[tool.ruff.lint.mccabe] +max-complexity = 10 [tool.ruff.format] indent-style = "space"