yegor256/takes

View on GitHub

Showing 117 of 117 total issues

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

    @Override
    @SuppressWarnings("PMD.AvoidCatchingGenericException")
    public Response act(final Request req) throws IOException {
        if (this.count <= 0) {
            throw new IllegalArgumentException(
Severity: Minor
Found in src/main/java/org/takes/tk/TkRetry.java - About 1 hr to fix

    Method next has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static State next(final InputStream stream, final State state,
            final ByteArrayOutputStream line) throws IOException {
            final int next = stream.read();
            if (next == -1) {
                throw new IOException("chunked stream ended unexpectedly");
    Severity: Minor
    Found in src/main/java/org/takes/rq/ChunkedInputStream.java - About 1 hr to fix

      Method header has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              @Override
              public List<String> header(final CharSequence key)
                  throws IOException {
                  final List<String> values = this.map().getOrDefault(
                      new UncheckedText(
      Severity: Minor
      Found in src/main/java/org/takes/rq/RqHeaders.java - About 1 hr to fix

        Method header has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                @Override
                public List<String> header(final CharSequence key)
                    throws IOException {
                    final List<String> values = this.map().getOrDefault(
                        new UncheckedText(
        Severity: Minor
        Found in src/main/java/org/takes/rs/RsHeaders.java - About 1 hr to fix

          Method chunkSize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static int chunkSize(final InputStream stream)
                  throws IOException {
                  final ByteArrayOutputStream baos = ChunkedInputStream.sizeLine(stream);
                  final String data = baos.toString(Charset.defaultCharset().name());
                  final int separator = data.indexOf(';');
          Severity: Minor
          Found in src/main/java/org/takes/rq/ChunkedInputStream.java - About 1 hr to fix

            Method urn has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    private Opt<String> urn(final String user, final String pwd) {
                        final String urn;
                        try {
                            urn = this.usernames.get(
                                String.format(
            Severity: Minor
            Found in src/main/java/org/takes/facets/auth/PsBasic.java - About 1 hr to fix

              Method asMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                  private static SortedMap<String, List<String>> asMap(final String query) {
                      final SortedMap<String, List<String>> params = new TreeMap<>();
                      if (query != null) {
                          for (final String pair : query.split("&")) {
              Severity: Minor
              Found in src/main/java/org/takes/misc/Href.java - 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

              Method parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                  private static Request parse(final InputStream input) throws IOException {
                      boolean eof = true;
                      final Collection<String> head = new LinkedList<>();
                      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
              Severity: Minor
              Found in src/main/java/org/takes/rq/RqLive.java - 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

              Method parse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                  private static Request parse(final InputStream input) throws IOException {
                      boolean eof = true;
                      final Collection<String> head = new LinkedList<>();
                      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
              Severity: Minor
              Found in src/main/java/org/takes/rq/RqLive.java - About 1 hr to fix

                Method response has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private Response response(final String home, final URI dest,
                        final com.jcabi.http.Response rsp) {
                        final Collection<String> hdrs = new LinkedList<>();
                        hdrs.add(
                            String.format(
                Severity: Minor
                Found in src/main/java/org/takes/tk/TkProxy.java - About 1 hr to fix

                  Method prepareDocType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static void prepareDocType(final InputStream body,
                          final Transformer transformer) throws IOException {
                          try {
                              final String html = "html";
                              final DocumentType doctype = RsPrettyXml.getDocType(body);
                  Severity: Minor
                  Found in src/main/java/org/takes/rs/RsPrettyXml.java - About 1 hr to fix

                    Method printHead has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public void printHead(final OutputStream output) throws IOException {
                            final String eol = "\r\n";
                            final Writer writer =
                                new OutputStreamWriter(output, StandardCharsets.UTF_8);
                            int pos = 0;
                    Severity: Minor
                    Found in src/main/java/org/takes/rs/RsPrint.java - About 1 hr to fix

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

                          @Override
                          public Opt<Response> route(final Request req) throws IOException {
                              final Iterator<String> headers =
                                  new RqHeaders.Base(req).header("Accept-Encoding").iterator();
                              final Opt<Response> resp;
                      Severity: Minor
                      Found in src/main/java/org/takes/facets/fork/FkEncoding.java - About 1 hr to fix

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

                            @Override
                            public Opt<Identity> enter(final Request trequest)
                                throws IOException {
                                final Href href = new RqHref.Base(trequest).href();
                                final Iterator<String> code = href.param(PsFacebook.CODE).iterator();
                        Severity: Minor
                        Found in src/main/java/org/takes/facets/auth/social/PsFacebook.java - About 1 hr to fix

                          Method cookie has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  @Override
                                  public Iterable<String> cookie(final CharSequence key)
                                      throws IOException {
                                      final Map<String, String> map = this.map();
                                      final String value = map.getOrDefault(
                          Severity: Minor
                          Found in src/main/java/org/takes/facets/cookies/RqCookies.java - About 1 hr to fix

                            Method equals has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                @Override
                                @SuppressFBWarnings("EQ_UNUSUAL")
                                public boolean equals(final Object that) {
                                    return new Unchecked<>(
                                        new Or(
                            Severity: Minor
                            Found in src/main/java/org/takes/rs/ResponseOf.java - About 1 hr to fix

                              Method equals has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  @Override
                                  @SuppressFBWarnings("EQ_UNUSUAL")
                                  public boolean equals(final Object that) {
                                      return new Unchecked<>(
                                          new Or(
                              Severity: Minor
                              Found in src/main/java/org/takes/rq/RequestOf.java - About 1 hr to fix

                                Method request has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                                    private com.jcabi.http.Request request(final Request req,
                                        final URI dest) throws Exception {
                                        final String method = new RqMethod.Base(req).method();
                                        com.jcabi.http.Request proxied = new JdkRequest(dest).method(method);
                                Severity: Minor
                                Found in src/main/java/org/takes/tk/TkProxy.java - About 1 hr to fix

                                  Method freshMap has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      private Map<String, List<String>> freshMap() throws IOException {
                                          final String body = new RqPrint(this.req).printBody();
                                          final Map<String, List<String>> map = new HashMap<>(1);
                                          for (final String pair : body.split("&")) {
                                              if (pair.isEmpty()) {
                                  Severity: Minor
                                  Found in src/main/java/org/takes/rq/form/RqFormBase.java - About 1 hr to fix

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

                                        @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
                                        private static MediaTypes getType(final Request req) throws IOException {
                                            MediaTypes list = new MediaTypes();
                                            final Iterable<String> headers = new RqHeaders.Base(req)
                                                .header("Content-Type");
                                    Severity: Major
                                    Found in src/main/java/org/takes/facets/fork/FkContentType.java and 1 other location - About 1 hr to fix
                                    src/main/java/org/takes/facets/fork/FkTypes.java on lines 112..124

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

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language