Showing 173 of 173 total issues

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

        if (tojos.isEmpty()) {
            if (this.scopedTojos().size() == 0) {
                Logger.warn(this, "Nothing to discover, since there are no programs");
            } else {
                Logger.info(this, "Nothing to discover, all programs checked already");
eo-maven-plugin/src/main/java/org/eolang/maven/ProbeMojo.java on lines 138..154

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

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

    @SuppressWarnings("PMD.CloseResource")
    private void execWithTimeout() throws ExecutionException, TimeoutException {
        final ExecutorService service = Executors.newSingleThreadExecutor();
        try {
            service.submit(
Severity: Minor
Found in eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java - About 1 hr to fix

    Method exitError has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private void exitError(final String msg, final Throwable exp)
            throws MojoFailureException {
            if (!this.unrollExitError) {
                return;
            }
    Severity: Minor
    Found in eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java - About 1 hr to fix

      Method take has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public <T> T take(final Class<T> type) {
              final byte[] weak = this.take();
              final Object strong;
              if (type.equals(Long.class)) {
                  strong = new BytesOf(weak).asNumber(Long.class);
      Severity: Minor
      Found in eo-runtime/src/main/java/org/eolang/Dataized.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 toPhi has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              private static Phi toPhi(final Object obj) {
                  final Phi phi;
                  final Phi eolang = Phi.Φ.take("org").take("eolang");
                  if (obj instanceof Boolean) {
                      if (obj.equals(true)) {
      Severity: Minor
      Found in eo-runtime/src/main/java/org/eolang/Data.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 probes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private Collection<ObjectName> probes(final Path file) throws FileNotFoundException {
              final Collection<ObjectName> objects = new ListOf<>(
                  new Mapped<>(
                      obj -> new OnCached(
                          new OnSwap(
      Severity: Minor
      Found in eo-maven-plugin/src/main/java/org/eolang/maven/ProbeMojo.java - About 1 hr to fix

        Method iterator has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            public Iterator<Dependency> iterator() {
                final Collection<Dependency> deps = new ListOf<>(this.delegate.iterator());
                final Map<String, Set<String>> conflicts = deps
                    .stream()

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

              @Override
              void exec() {
                  final Collection<ForeignTojo> tojos = this.scopedTojos().withXmir();
                  final int total = new OptimizedTojos(
                      new Filtered<>(
          Severity: Minor
          Found in eo-maven-plugin/src/main/java/org/eolang/maven/VerifyMojo.java - About 1 hr to fix

            Method failures has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @SuppressWarnings("unchecked")
                public Collection<String> failures() throws IOException {
                    final Yaml yaml = new Yaml();
                    final Map<String, Object> map = yaml.load(this.script);
                    final String src = map.get("eo").toString();
            Severity: Minor
            Found in eo-parser/src/main/java/org/eolang/parser/CheckPack.java - About 1 hr to fix

              Method φTerm has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Override
                  public String φTerm() {
                      final List<String> list = new ArrayList<>(this.attrs.size());
                      final String format = "%s ↦ %s";
                      if (this.data.get() != null) {
              Severity: Minor
              Found in eo-runtime/src/main/java/org/eolang/PhDefault.java - About 1 hr to fix

                Method makeGraph has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private void makeGraph(final String xembly, final Path sodg) throws IOException {
                        if (this.generateGraphFiles) {
                            final Directives all = new Directives(xembly);
                            Logger.debug(
                                this, "There are %d Xembly directives for %s",
                Severity: Minor
                Found in eo-maven-plugin/src/main/java/org/eolang/maven/SodgMojo.java - About 1 hr to fix

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

                      @SuppressWarnings("unchecked")
                      private static ConcurrentHashMap<String, String> load(final Path src) throws IOException {
                          try (ObjectInputStream map = new ObjectInputStream(
                              new ByteArrayInputStream(
                                  Base64.getDecoder().decode(
                  Severity: Minor
                  Found in eo-maven-plugin/src/main/java/org/eolang/maven/rust/Names.java - About 1 hr to fix

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

                        @SuppressWarnings("PMD.AvoidAccessToStaticMembersViaThis")
                        private int keepThem(final Iterable<? extends PlacedTojo> tojos) throws IOException {
                            int deleted = 0;
                            int remained = 0;
                            for (final PlacedTojo tojo : tojos) {
                    Severity: Minor
                    Found in eo-maven-plugin/src/main/java/org/eolang/maven/UnplaceMojo.java - About 1 hr to fix

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

                          @Override
                          public Phi lambda() throws Exception {
                              final String locator = this.take("code").locator().split(":")[0];
                              final String name = Optional.ofNullable(NAMES.get(locator))
                                  .orElseThrow(() -> new ExNative("No native function for %s", locator));
                      Severity: Minor
                      Found in eo-runtime/src/main/java/EOorg/EOeolang/EOrust.java - About 1 hr to fix

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

                            private static void run(final List<String> opts) throws Exception {
                                final String path = new JavaPath(opts.get(0)).toString();
                                final Phi app;
                                try {
                                    Main.LOGGER.fine(String.format("Loading class %s...", path));
                        Severity: Minor
                        Found in eo-runtime/src/main/java/org/eolang/Main.java - About 1 hr to fix

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

                              @Override
                              public XML parsed() throws IOException {
                                  final XePhiListener xel = new XePhiListener(this.name);
                                  final ParsingErrors spy = new ParsingErrors(this.input);
                                  final PhiLexer lexer = new PhiLexer(
                          Severity: Minor
                          Found in eo-parser/src/main/java/org/eolang/parser/PhiSyntax.java - About 1 hr to fix

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

                                @Override
                                public void exec() throws IOException {
                                    final List<Path> all = new Walk(this.classesDir.toPath()).stream()
                                        .filter(
                                            file -> this.includes.stream().anyMatch(
                            Severity: Minor
                            Found in eo-maven-plugin/src/main/java/org/eolang/maven/UnspileMojo.java - About 1 hr to fix

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

                                  @Override
                                  public void accept(final Path sources, final Path destination) {
                                      final String src = sources.toString();
                                      final String dst = destination.toString();
                                      try {
                              Severity: Minor
                              Found in eo-maven-plugin/src/main/java/org/eolang/maven/CopiedResources.java - About 1 hr to fix

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

                                    @Override
                                    public int find(final String name) {
                                        if (name == null) {
                                            throw new IllegalArgumentException(
                                                "Argument name is null"
                                Severity: Minor
                                Found in eo-runtime/src/main/java/org/eolang/UniverseDefault.java - About 1 hr to fix

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

                                      @Override
                                      public void exec() {
                                          final Collection<ForeignTojo> tojos = this.scopedTojos().notDiscovered();
                                          final Collection<String> discovered = new HashSet<>();
                                          for (final ForeignTojo tojo : tojos) {
                                  Severity: Minor
                                  Found in eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language