yegor256/takes

View on GitHub

Showing 72 of 117 total issues

HttpServletRequestFake has 72 methods (exceeds 20 allowed). Consider refactoring.
Open

@SuppressWarnings({
    "PMD.TooManyMethods",
    "PMD.ExcessiveImports",
    "PMD.ExcessivePublicCount"
})
Severity: Major
Found in src/main/java/org/takes/servlet/HttpServletRequestFake.java - About 1 day to fix

    File HttpServletRequestFake.java has 431 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * The MIT License (MIT)
     *
     * Copyright (c) 2014-2024 Yegor Bugayenko
     *
    Severity: Minor
    Found in src/main/java/org/takes/servlet/HttpServletRequestFake.java - About 6 hrs to fix

      HttpServletResponseFake has 38 methods (exceeds 20 allowed). Consider refactoring.
      Open

      @SuppressWarnings("PMD.TooManyMethods")
      public final class HttpServletResponseFake implements HttpServletResponse {
          /**
           * A Takes response.
           */
      Severity: Minor
      Found in src/main/java/org/takes/servlet/HttpServletResponseFake.java - About 5 hrs to fix

        Method wrap has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            @SuppressWarnings("PMD.AvoidCatchingGenericException")
            private static Response wrap(final Response res, final Fallback fbk,
                final Request req) {
                return new ResponseOf(
                    () -> {
        Severity: Minor
        Found in src/main/java/org/takes/facets/fallback/TkFallback.java - About 2 hrs 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

        VerboseList has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        @SuppressWarnings("PMD.TooManyMethods")
        public final class VerboseList<T> implements List<T> {
        
            /**
             * Original list.
        Severity: Minor
        Found in src/main/java/org/takes/misc/VerboseList.java - About 2 hrs to fix

          Method copy has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public void copy() throws IOException {
                  int match = 0;
                  boolean cont = true;
                  while (cont) {
                      if (!this.buffer.hasRemaining()) {
          Severity: Minor
          Found in src/main/java/org/takes/rq/multipart/CopyBytesUntilBoundary.java - About 2 hrs 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

          Method act has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              @SuppressWarnings("PMD.AvoidCatchingGenericException")
              public Response act(final Request req) throws Exception {
                  final Scalar<Long> time = System::currentTimeMillis;
                  final long start = time.value();
          Severity: Major
          Found in src/main/java/org/takes/tk/TkSlf4j.java - About 2 hrs to fix

            Method init has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                @SuppressWarnings("PMD.CyclomaticComplexity")
                public void init() throws ServletException {
                    super.init();
                    final String cname = this.getServletConfig()
            Severity: Major
            Found in src/main/java/org/takes/servlet/SrvTake.java - About 2 hrs to fix

              Method exec has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public void exec(final FtRemote.Script script) throws Exception {
                      final AtomicBoolean exit = new AtomicBoolean();
                      final CountDownLatch latch = new CountDownLatch(1);
                      final Thread thread = new Thread(
                          () -> {
              Severity: Major
              Found in src/main/java/org/takes/http/FtRemote.java - About 2 hrs to fix

                Method toString has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    @Override
                    public String toString() {
                        final StringBuilder text = new StringBuilder(this.bare());
                        if (!this.params.isEmpty()) {
                            boolean first = true;
                Severity: Minor
                Found in src/main/java/org/takes/misc/Href.java - About 2 hrs 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

                Method wrap has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @SuppressWarnings("PMD.AvoidCatchingGenericException")
                    private static Response wrap(final Response res, final Fallback fbk,
                        final Request req) {
                        return new ResponseOf(
                            () -> {
                Severity: Major
                Found in src/main/java/org/takes/facets/fallback/TkFallback.java - About 2 hrs to fix

                  Method exec has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public void exec(final MainRemote.Script script) throws Exception {
                          final File file = File.createTempFile("takes-", ".txt");
                          if (!file.delete()) {
                              throw new IOException(
                                  String.format(
                  Severity: Major
                  Found in src/main/java/org/takes/http/MainRemote.java - About 2 hrs to fix

                    Method enter has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        @Override
                        public Opt<Identity> enter(final Request req) throws IOException {
                            // @checkstyle ExecutableStatementCount (100 lines)
                            Opt<Identity> user = new Opt.Empty<>();
                            final UncheckedText head = new Unchecked<>(
                    Severity: Minor
                    Found in src/main/java/org/takes/facets/auth/PsToken.java - About 2 hrs to fix

                      Method requests has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private Map<String, List<Request>> requests(
                              final Request req) throws IOException {
                              final String header = new RqHeaders.Smart(req).single("Content-Type");
                              final Unchecked<Boolean> multipart = new Unchecked<>(
                                  new StartsWith(
                      Severity: Minor
                      Found in src/main/java/org/takes/rq/multipart/RqMtBase.java - About 1 hr to fix

                        Method make has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static Map<Integer, String> make() {
                                final Map<Integer, String> map = new HashMap<>(0);
                                map.put(HttpURLConnection.HTTP_OK, "OK");
                                map.put(HttpURLConnection.HTTP_CREATED, "Created");
                                map.put(HttpURLConnection.HTTP_ACCEPTED, "Accepted");
                        Severity: Minor
                        Found in src/main/java/org/takes/rs/RsWithStatus.java - About 1 hr to fix

                          Method route has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private static Response route(final Take take, final Fallback fbk,
                                  final Request req) throws Exception {
                                  final long start = System.currentTimeMillis();
                                  Response res;
                                  try {
                          Severity: Minor
                          Found in src/main/java/org/takes/facets/fallback/TkFallback.java - About 1 hr to fix

                            Method enter has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                @Override
                                public Opt<Identity> enter(final Request request) throws IOException {
                                    final Iterator<String> headers = new RqHeaders.Smart(request)
                                        .header("authorization").iterator();
                                    if (!headers.hasNext()) {
                            Severity: Minor
                            Found in src/main/java/org/takes/facets/auth/PsBasic.java - About 1 hr to fix

                              Method start has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  @Override
                                  public void start(final Exit exit) throws IOException {
                                      final Take tks;
                                      if (this.options.hitRefresh()) {
                                          tks = request -> this.take.act(
                              Severity: Minor
                              Found in src/main/java/org/takes/http/FtCli.java - About 1 hr to fix

                                Method map has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                                        private Map<String, List<String>> map() throws IOException {
                                            final Iterator<String> head = this.head().iterator();
                                            if (!head.hasNext()) {
                                                throw new HttpException(
                                Severity: Minor
                                Found in src/main/java/org/takes/rs/RsHeaders.java - About 1 hr to fix

                                  Method map has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                                          private Map<String, List<String>> map() throws IOException {
                                              final Iterator<String> head = this.head().iterator();
                                              if (!head.hasNext()) {
                                                  throw new HttpException(
                                  Severity: Minor
                                  Found in src/main/java/org/takes/rq/RqHeaders.java - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language