yegor256/takes

View on GitHub

Showing 117 of 117 total issues

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

    @Override
    @SuppressFBWarnings("EQ_UNUSUAL")
    public boolean equals(final Object that) {
        return new Unchecked<>(
            new Or(
Severity: Major
Found in src/main/java/org/takes/rs/ResponseOf.java and 1 other location - About 2 hrs to fix
src/main/java/org/takes/rq/RequestOf.java on lines 89..118

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

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

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

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

                    @Override
                    public List<String> header(final CharSequence key)
                        throws IOException {
                        final List<String> values = this.map().getOrDefault(
                            new UncheckedText(
            Severity: Major
            Found in src/main/java/org/takes/rs/RsHeaders.java and 2 other locations - About 1 hr to fix
            src/main/java/org/takes/rq/RqHeaders.java on lines 92..123
            src/main/java/org/takes/rq/form/RqFormBase.java on lines 79..107

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

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

                @Override
                public Iterable<String> param(final CharSequence key)
                    throws IOException {
                    final List<String> values = this.map().getOrDefault(
                        new UncheckedText(
            Severity: Major
            Found in src/main/java/org/takes/rq/form/RqFormBase.java and 2 other locations - About 1 hr to fix
            src/main/java/org/takes/rq/RqHeaders.java on lines 92..123
            src/main/java/org/takes/rs/RsHeaders.java on lines 92..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 100.

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

                    @Override
                    public List<String> header(final CharSequence key)
                        throws IOException {
                        final List<String> values = this.map().getOrDefault(
                            new UncheckedText(
            Severity: Major
            Found in src/main/java/org/takes/rq/RqHeaders.java and 2 other locations - About 1 hr to fix
            src/main/java/org/takes/rq/form/RqFormBase.java on lines 79..107
            src/main/java/org/takes/rs/RsHeaders.java on lines 92..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 100.

            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

            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

                Method unsalt has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @SuppressWarnings("PMD.CyclomaticComplexity")
                    private static byte[] unsalt(final byte[] text) {
                        if (text.length == 0) {
                            throw new DecodingException("empty input");
                        }
                Severity: Minor
                Found in src/main/java/org/takes/facets/auth/codecs/CcSalted.java - About 1 hr to fix

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

                  /*
                   * The MIT License (MIT)
                   *
                   * Copyright (c) 2014-2024 Yegor Bugayenko
                   *
                  src/main/java/org/takes/facets/auth/social/XeFacebookLink.java on lines 1..95

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

                  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

                  /*
                   * The MIT License (MIT)
                   *
                   * Copyright (c) 2014-2024 Yegor Bugayenko
                   *
                  src/main/java/org/takes/facets/auth/social/XeGithubLink.java on lines 1..95

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

                  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

                  Method token has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private String token(final String home, final String code)
                          throws IOException {
                          final String response = this.request
                              .uri()
                              .set(
                  Severity: Minor
                  Found in src/main/java/org/takes/facets/auth/social/PsFacebook.java - About 1 hr to fix

                    Method copy has 34 lines of code (exceeds 25 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 1 hr to fix

                      Method start has a Cognitive Complexity of 11 (exceeds 5 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

                      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 resolve has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                              @Override
                              public Source resolve(final String href, final String base)
                                  throws TransformerException {
                                  final URI uri;
                                  if (base == null || base.isEmpty()) {
                      Severity: Minor
                      Found in src/main/java/org/takes/rs/RsXslt.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 resolve has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              @Override
                              public Source resolve(final String href, final String base)
                                  throws TransformerException {
                                  final URI uri;
                                  if (base == null || base.isEmpty()) {
                      Severity: Minor
                      Found in src/main/java/org/takes/rs/RsXslt.java - About 1 hr to fix

                        Method head has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            @Override
                            public Iterable<String> head() {
                                final Collection<String> head = new LinkedList<>();
                                head.add(new HttpHead(this.sreq).toString());
                                final Collection<String> names = Collections.list(
                        Severity: Minor
                        Found in src/main/java/org/takes/servlet/RqFrom.java - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language