Fakultas Ilmu Komputer UI

Commit 68d6d6ba authored by Kefas Satrio Bangkit Solidedantyo's avatar Kefas Satrio Bangkit Solidedantyo
Browse files

Uncomment sonarqube in CI and remove code smells

parent 0ec47cc4
stages:
- test
# - sonar-scanner
- sonar-scanner
- deploy
pylint:
......@@ -36,18 +36,18 @@ UnitTest:
paths:
- coverage.xml
# SonarScanner:
# image:
# name: sonarsource/sonar-scanner-cli:4.6
# entrypoint: [""]
# stage: sonar-scanner
# script:
# - sonar-scanner
# -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
# -Dsonar.login=$SONARQUBE_TOKEN
# -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
# -Dsonar.branch.name=$CI_COMMIT_REF_NAME
# -Dsonar.python.coverage.reportPaths=coverage.xml
SonarScanner:
image:
name: sonarsource/sonar-scanner-cli:4.6
entrypoint: [""]
stage: sonar-scanner
script:
- sonar-scanner
-Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
-Dsonar.login=$SONARQUBE_TOKEN
-Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
-Dsonar.branch.name=$CI_COMMIT_REF_NAME
-Dsonar.python.coverage.reportPaths=coverage.xml
DeploymentStaging:
image: ruby:2.4
......
......@@ -38,10 +38,12 @@ class CustomLoginSerializer(LoginSerializer):
raise exceptions.ValidationError(msg)
def create(self, validated_data):
pass
pass # Empty because the function is not needed
# but Pylint demanded to implement it anyway
def update(self, instance, validated_data):
pass
pass # Empty because the function is not needed
# but Pylint demanded to implement it anyway
class CustomRegisterSerializer(RegisterSerializer):
......@@ -56,10 +58,12 @@ class CustomRegisterSerializer(RegisterSerializer):
}
def create(self, validated_data):
pass
pass # Empty because the function is not needed
# but Pylint demanded to implement it anyway
def update(self, instance, validated_data):
pass
pass # Empty because the function is not needed
# but Pylint demanded to implement it anyway
def save(self, request):
user = super().save(request)
......
CART_NOT_FOUND_MESSAGE = "Cart is not found."
......@@ -4,6 +4,7 @@ from rest_framework import viewsets, status
from rest_framework.response import Response
import requests
from constants.transaction_status import TransactionStatus as TRANSACTION_STATUS
from constants.string_constants import CART_NOT_FOUND_MESSAGE
from dietela_program.serializers import DietelaProgramSerializer
from dietela_program.models import DietelaProgram
from .serializers import CartSerializer
......@@ -67,7 +68,8 @@ class PaymentViewSet(viewsets.ViewSet):
try:
cart = Cart.objects.get(pk=cart_id)
except Cart.DoesNotExist:
return Response({'message': 'Cart is not found.'}, status=status.HTTP_400_BAD_REQUEST)
return Response({'message': CART_NOT_FOUND_MESSAGE}, \
status=status.HTTP_400_BAD_REQUEST)
payload = self.create_payload(cart)
response = requests.post(self.MIDTRANS_URL, payload, headers=self.POST_PAYMENT_HEADERS)
json_response = json.loads(response.content)
......@@ -88,7 +90,8 @@ class TransactionStatusViewSet(viewsets.ViewSet):
try:
cart = Cart.objects.get(pk=cart_id)
except Cart.DoesNotExist:
return Response({'message': 'Cart is not found.'}, status=status.HTTP_400_BAD_REQUEST)
return Response({'message': CART_NOT_FOUND_MESSAGE}, \
status=status.HTTP_400_BAD_REQUEST)
if transaction_status_code == 200:
cart.transaction_status = TRANSACTION_STATUS.SUCCESS
......@@ -111,7 +114,8 @@ class MidtransRedirectionViewSet(viewsets.ViewSet):
try:
cart = Cart.objects.get(pk=cart_id)
except Cart.DoesNotExist:
return Response({'message': 'Cart is not found.'}, status=status.HTTP_400_BAD_REQUEST)
return Response({'message': CART_NOT_FOUND_MESSAGE}, \
status=status.HTTP_400_BAD_REQUEST)
cart.transaction_status = transaction_status
cart.save()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment