MiniDigger/Hangar

View on GitHub
apiV2/app/controllers/apiv2/ApiV2Controller.scala

Summary

Maintainability
D
2 days
Test Coverage

File ApiV2Controller.scala has 635 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package controllers.apiv2

import scala.language.higherKinds

import java.nio.file.Path
Severity: Major
Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala - About 1 day to fix

    Method listProjects has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          q: Option[String],
          categories: Seq[Category],
          tags: Seq[String],
          owner: Option[String],
          sort: Option[ProjectSortingStrategy],
    Severity: Major
    Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala - About 1 hr to fix

      Method showUserAction has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            user: String,
            sort: Option[ProjectSortingStrategy],
            limit: Option[Long],
            offset: Long,
            query: (
      Severity: Minor
      Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala - About 45 mins to fix

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

            case APIScope.OrganizationScope(organizationName) =>
              OptionT(
                service.runDBIO(
                  TableQuery[OrganizationTable].filter(_.name === organizationName).map(_.id).result.headOption
                )
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 1 hr to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 119..123

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

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

            case APIScope.ProjectScope(pluginId) =>
              OptionT(
                service.runDBIO(TableQuery[ProjectTableMain].filter(_.pluginId === pluginId).map(_.id).result.headOption)
              ).map(id => ProjectScope(id))
            case APIScope.OrganizationScope(organizationName) =>
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 1 hr to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 123..128

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

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

          def apiVecDbAction[A: Encoder](
              perms: Permission,
              scope: APIScope
          )(action: ApiRequest[AnyContent] => doobie.ConnectionIO[Vector[A]]): Action[AnyContent] =
            ApiAction(perms, scope).asyncF { request =>
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 50 mins to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 146..151

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

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

          def apiDbAction[A: Encoder](perms: Permission, scope: APIScope)(
              action: ApiRequest[AnyContent] => doobie.ConnectionIO[A]
          ): Action[AnyContent] =
            ApiAction(perms, scope).asyncF { request =>
              service.runDbCon(action(request)).map(a => Ok(a.asJson))
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 50 mins to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 174..180

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

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

          def hasAll(
              permissions: Seq[NamedPermission],
              pluginId: Option[String],
              organizationName: Option[String]
          ): Action[AnyContent] =
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 30 mins to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 365..370

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

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

          def hasAny(
              permissions: Seq[NamedPermission],
              pluginId: Option[String],
              organizationName: Option[String]
          ): Action[AnyContent] =
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 30 mins to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 358..363

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

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

            service.insert(sessionToInsert).map { key =>
              Ok(
                ReturnedApiSession(
                  key.token,
                  LocalDateTime.ofInstant(key.expires, ZoneOffset.UTC),
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 30 mins to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 257..265

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

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

              service.insert(sessionToInsert).map { key =>
                Ok(
                  ReturnedApiSession(
                    key.token,
                    LocalDateTime.ofInstant(key.expires, ZoneOffset.UTC),
        Severity: Minor
        Found in apiV2/app/controllers/apiv2/ApiV2Controller.scala and 1 other location - About 30 mins to fix
        apiV2/app/controllers/apiv2/ApiV2Controller.scala on lines 189..197

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

        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

        There are no issues that match your filters.

        Category
        Status