MAKENTNU/web

View on GitHub

Showing 230 of 230 total issues

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

if (day < endTime && endTime <= day.nextDay()) {
$element.append($(`<div class="selection end time">${endTime.timeString()}</div>`));
 
// Add an element for expanding the selection if the selection is finished
if (!this.selecting) {
Severity: Major
Found in src/make_queue/static/make_queue/js/calendar.js and 1 other location - About 5 hrs to fix
src/make_queue/static/make_queue/js/calendar.js on lines 234..252

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

if (day <= startTime && startTime < day.nextDay()) {
$element.append($(`<div class="selection start time">${startTime.timeString()}</div>`));
 
// Add an element for expanding the selection if the selection is finished
if (!this.selecting) {
Severity: Major
Found in src/make_queue/static/make_queue/js/calendar.js and 1 other location - About 5 hrs to fix
src/make_queue/static/make_queue/js/calendar.js on lines 255..273

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

if (currentOverlap > period.max_inside) {
// If the overlap with the current time period is greater than the maximum allowed inside then
// shrink till it is equal to that.
endTime = new Date(endTime.valueOf() - (currentOverlap - period.max_inside) * 60 * 60 * 1000);
} else if (currentOverlap > period.max_crossed) {
src/make_queue/static/make_queue/js/reservation_rule_utils.js on lines 157..172

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

if (currentOverlap > period.max_inside) {
// If the overlap with the current time period is greater than the maximum allowed inside then
// shrink till it is equal to that.
startTime = new Date(startTime.valueOf() + (currentOverlap - period.max_inside) * 60 * 60 * 1000);
} else if (currentOverlap > period.max_crossed) {
src/make_queue/static/make_queue/js/reservation_rule_utils.js on lines 139..154

Function validate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

def validate(self):
# User needs to be able to print, for it to be able to reserve the printers
if not self.machine.can_user_use(self.user):
return False
 
 
Severity: Minor
Found in src/make_queue/models/reservation.py - About 4 hrs to fix

Cyclomatic complexity is too high in class ReservationRuleForm. (23)
Open

class ReservationRuleForm(forms.ModelForm):
class Meta:
model = ReservationRule
fields = ['start_time', 'days_changed', 'end_time', 'start_days', 'max_hours', 'max_inside_border_crossed', 'machine_type']
widgets = {

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

$("#special-checkbox").checkbox({
onChange: function () {
$("#special-input").toggleClass("display-none", !$(this).is(":checked"));
if ($(this).is(":checked")) {
$("#event-checkbox").checkbox("uncheck");
Severity: Major
Found in src/make_queue/static/make_queue/js/reservation_form.js and 1 other location - About 4 hrs to fix
src/make_queue/static/make_queue/js/reservation_form.js on lines 205..216

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

$("#event-checkbox").checkbox({
onChange: function () {
$("#event-name-input").toggleClass("display-none", !$(this).is(":checked"));
if ($(this).is(":checked")) {
$("#special-checkbox").checkbox("uncheck");
Severity: Major
Found in src/make_queue/static/make_queue/js/reservation_form.js and 1 other location - About 4 hrs to fix
src/make_queue/static/make_queue/js/reservation_form.js on lines 217..228

Cyclomatic complexity is too high in method validate. (22)
Open

def validate(self):
# User needs to be able to print, for it to be able to reserve the printers
if not self.machine.can_user_use(self.user):
return False
 
 
Severity: Minor
Found in src/make_queue/models/reservation.py by radon

Cyclomatic complexity is too high in method clean. (22)
Open

def clean(self):
cleaned_data = super().clean()
start_time = cleaned_data.get('start_time')
end_time = cleaned_data.get('end_time')
days_changed = cleaned_data.get('days_changed')

Function showDetailedMemberInformation has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function showDetailedMemberInformation(member) {
/**
* Displays the selected members' information in a popup modal.
*/
const textAttributeNamesToValues = {
Severity: Major
Found in src/internal/static/internal/js/member_list.js - About 3 hrs to fix

    Function modifyToFirstValid has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function modifyToFirstValid(rules, startTime, endTime, modificationDirection) {
    /**
    * Modifies either startTime (modificationDirection 0) or endTime (modificationDirection 1) until the period
    * [startTime, endTime] is valid for the given set of rules.
    */
    Severity: Minor
    Found in src/make_queue/static/make_queue/js/reservation_rule_utils.js - About 3 hrs to fix

    Function setup has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function setup() {
    /**
    * Setup of the global state and actions.
    */
    $filterStatusInput.change(() => {
    Severity: Major
    Found in src/internal/static/internal/js/member_list.js - About 3 hrs to fix

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

      setDirty: function() {
      this.isDirty = true;
      this.history[0] = this.history[1];
      this.history[1] = dirty;
       
       
      Severity: Major
      Found in src/web/static/lib/jquery/jquery.dirty.js and 1 other location - About 3 hrs to fix
      src/web/static/lib/jquery/jquery.dirty.js on lines 206..214

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

      setClean: function() {
      this.isDirty = false;
      this.history[0] = this.history[1];
      this.history[1] = clean;
       
       
      Severity: Major
      Found in src/web/static/lib/jquery/jquery.dirty.js and 1 other location - About 3 hrs to fix
      src/web/static/lib/jquery/jquery.dirty.js on lines 196..204

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

      event_adminpatterns = [
      path("", event_views.AdminEventListView.as_view(), name='admin_event_list'),
      path("add/", event_views.EventCreateView.as_view(), name='event_create'),
      path("<int:pk>/", include(specific_event_adminpatterns)),
      path("participants/search/", event_views.AdminEventParticipantsSearchView.as_view(), name='admin_event_participants_search'),
      Severity: Major
      Found in src/news/urls.py and 1 other location - About 3 hrs to fix
      src/make_queue/urls.py on lines 103..107

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

      quota_adminpatterns = [
      path("", quota_views.AdminQuotaPanelView.as_view(), name='admin_quota_panel'),
      path("add/", quota_views.QuotaCreateView.as_view(), name='quota_create'),
      path("<int:pk>/", include(specific_quota_adminpatterns)),
      path("users/<int:pk>/", quota_views.AdminUserQuotaListView.as_view(), name='admin_user_quota_list'),
      Severity: Major
      Found in src/make_queue/urls.py and 1 other location - About 3 hrs to fix
      src/news/urls.py on lines 75..79

      Cyclomatic complexity is too high in class AdminSuggestSkillView. (14)
      Open

      class AdminSuggestSkillView(PermissionRequiredMixin, TemplateView):
      permission_required = ('checkin.add_suggestskill',)
      template_name = 'checkin/admin_suggest_skill.html'
      extra_context = {
      'suggestions': SuggestSkill.objects.all(),
      Severity: Minor
      Found in src/checkin/views.py by radon

      Cyclomatic complexity is too high in method post. (13)
      Open

      def post(self, request):
      suggestion = request.POST.get('suggested-skill')
      suggestion_english = request.POST.get('suggested-skill-english')
      profile = request.user.profile
      image = request.FILES.get('image')
      Severity: Minor
      Found in src/checkin/views.py by radon

      Function compile_fieldsets has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def compile_fieldsets(self, custom_fieldsets: Iterable[dict], form: Form):
      fieldsets = []
      for fieldset in copy.deepcopy(custom_fieldsets):
      if not fieldset:
      continue
      Severity: Minor
      Found in src/util/view_utils.py - About 2 hrs to fix
      Severity
      Category
      Status
      Source
      Language