Cloud-CV/EvalAI

View on GitHub

Showing 1,371 of 1,371 total issues

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

                parameters.data = {
                    "new_password1": vm.getUser.new_password1,
                    "new_password2": vm.getUser.new_password2,
                    "uid": $state.params.user_id,
                    "token": $state.params.reset_token,
Severity: Major
Found in frontend/src/js/controllers/authCtrl.js and 3 other locations - About 1 hr to fix
frontend/src/js/controllers/authCtrl.js on lines 96..101
frontend/src/js/controllers/changePwdCtrl.js on lines 64..69
frontend/src/js/controllers/profileCtrl.js on lines 316..321

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

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

                parameters.data = {
                    "username": vm.regUser.name,
                    "password1": vm.regUser.password,
                    "password2": vm.regUser.confirm_password,
                    "email": vm.regUser.email
Severity: Major
Found in frontend/src/js/controllers/authCtrl.js and 3 other locations - About 1 hr to fix
frontend/src/js/controllers/authCtrl.js on lines 342..347
frontend/src/js/controllers/changePwdCtrl.js on lines 64..69
frontend/src/js/controllers/profileCtrl.js on lines 316..321

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

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

            parameters.data = {
                "old_password": vm.user.old_password,
                "new_password1": vm.user.new_password1,
                "new_password2": vm.user.new_password2,
                "uid": $state.params.user_id,
Severity: Major
Found in frontend/src/js/controllers/changePwdCtrl.js and 3 other locations - About 1 hr to fix
frontend/src/js/controllers/authCtrl.js on lines 96..101
frontend/src/js/controllers/authCtrl.js on lines 342..347
frontend/src/js/controllers/profileCtrl.js on lines 316..321

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

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

Function onSuccess has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                    onSuccess: function() {

                        vm.team.error = false;
                        $rootScope.notify("info", "You have removed yourself successfully");

Severity: Minor
Found in frontend/src/js/controllers/teamsCtrl.js - About 1 hr to fix

    Function onSuccess has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                        onSuccess: function() {
                            vm.team.error = false;
                            $rootScope.notify("info", "You have removed yourself successfully");
    
                            var parameters = {};
    Severity: Minor
    Found in frontend/src/js/controllers/challengeHostTeamsCtrl.js - About 1 hr to fix

      Function create_static_code_upload_submission_job_object has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def create_static_code_upload_submission_job_object(message, challenge):
          """Function to create the static code upload pod AWS EKS Job object
      
          Arguments:
              message {[dict]} -- Submission message from AWS SQS queue
      Severity: Minor
      Found in scripts/workers/code_upload_submission_worker.py - About 1 hr to fix

        Function ngOnInit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          ngOnInit() {
            this.challengeService.currentChallenge.subscribe((challenge) => {
              this.challenge = challenge;
            });
        
        

          Function stopParticipation has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            stopParticipation(event) {
              event.preventDefault();
              const participationState = this.challenge['is_registration_open'] ? 'Close' : 'Open';
              const closeParticipationMsg = 'Participation is closed successfully';
              const openParticipationMsg = 'Participation is opened successfully';

            Function editEvaluationScript has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              editEvaluationScript() {
                const SELF = this;
                SELF.apiCall = (params) => {
                  const FORM_DATA: FormData = new FormData();
                  FORM_DATA.append('evaluation_script', params['evaluation_script']);

              Function ngOnInit has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                ngOnInit() {
                  if (this.authService.isLoggedIn()) {
                    this.isLoggedIn = true;
                  }
                  this.routerPublic = this.router;

                Function start_job has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def start_job():
                
                    # Get metrics
                    staff_evalai_interface = create_evalai_interface(STAFF_AUTH_TOKEN)
                
                
                Severity: Minor
                Found in scripts/monitoring/auto_scale_eks_nodes.py - About 1 hr 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 stop_workers_for_challenges has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def stop_workers_for_challenges(response):
                    for challenge in response["results"]:
                        challenge_id = challenge["id"]
                        workers = challenge["workers"]
                        approved_by_admin = challenge["approved_by_admin"]
                Severity: Minor
                Found in scripts/monitoring/auto_stop_workers.py - About 1 hr 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 remove_participant_team_from_challenge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def remove_participant_team_from_challenge(
                    request, challenge_pk, participant_team_pk
                ):
                    """
                    API to remove the participant team from a challenge
                Severity: Minor
                Found in apps/participants/views.py - About 1 hr 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 manage_ec2_instance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def manage_ec2_instance(request, challenge_pk, action):
                    if not request.user.is_staff:
                        response_data = {
                            "error": "Sorry, you are not authorized for access EC2 operations."
                        }
                Severity: Minor
                Found in apps/challenges/views.py - About 1 hr 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 star_challenge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def star_challenge(request, challenge_pk):
                    """
                    API endpoint for starring and unstarring
                    a challenge.
                    """
                Severity: Minor
                Found in apps/challenges/views.py - About 1 hr 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 create_service_by_challenge_pk has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                def create_service_by_challenge_pk(client, challenge, client_token):
                    """
                    Creates the worker service for a challenge, and sets the number of workers to one.
                
                    Parameters:
                Severity: Minor
                Found in apps/challenges/aws_utils.py - About 1 hr 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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self, *args, **kwargs):
                        super(ChallengePhaseCreateSerializer, self).__init__(*args, **kwargs)
                        context = kwargs.get("context")
                        if context:
                            challenge = context.get("challenge")
                Severity: Minor
                Found in apps/challenges/serializers.py - About 1 hr 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 selectPhaseSplitId has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  selectPhaseSplitId(id, self) {
                    let i = 0;
                    for (i = 0; i < self.filteredPhaseSplits.length; i++) {
                      if (parseInt(id, 10) === self.filteredPhaseSplits[i]['id']) {
                        self.selectedPhaseSplit = self.filteredPhaseSplits[i];

                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 onSuccess has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                                onSuccess: function() {
                                    $rootScope.notify("success", "Team " + vm.team.name + " has been created successfully!");
                                    vm.team.error = false;
                                    vm.stopLoader();
                                    vm.team = {};
                Severity: Minor
                Found in frontend/src/js/controllers/challengeCtrl.js - About 1 hr to fix

                  Function startLoadingLogs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          vm.startLoadingLogs = function () {
                              vm.logs_poller = $interval(function () {
                                  if (vm.evaluation_module_error) {
                                      vm.workerLogs = [];
                                      vm.workerLogs.push(vm.evaluation_module_error);
                  Severity: Minor
                  Found in frontend/src/js/controllers/challengeCtrl.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language