Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch fix sonarqube failures #1930

Merged
merged 4 commits into from
Mar 31, 2023
Merged

Conversation

mximp
Copy link
Contributor

@mximp mximp commented Mar 21, 2023

#1897 Fixes of SonarCloud findings.
Add puzzles for the rest.

@mximp
Copy link
Contributor Author

mximp commented Mar 21, 2023

@yegor256 please reveiw

* This includes call of {@link ThreadLocal#remove()} method to prevent
* memory leaks.
*/
public static void cleanUp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mximp I don't see anyone calling this method. I think, remove() is supposed to be called right after we use TERMS, not in a separate method. But I'm not sure...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256 You are right - the method is not called by anyone. The thing is I cannot define the moment "right after TERM is used". It's static and holds the value which is required throughout the program execution. So I see correct place for remove to be called before program exits. But that doesn't make sense.
So in this case I just created fake method according to SonarQube expectations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mximp as I understood from this, we can call remove() right after the use of the variable

Copy link
Contributor Author

@mximp mximp Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yegor256 From this post it is still not clear how to apply in our case. According to Java Docs:

Removes the current thread's value for this thread-local variable. If this thread-local variable is subsequently read by the current thread, its value will be reinitialized by invoking its initialValue() method, unless its value is set by the current thread in the interim. This may result in multiple invocations of the initialValue method in the current thread.

Which means that if we call this method on TERM it will be reset, i.e. cache of the vertexes will be cleared. Which is not what we want. It would make sense if we have clear lifecycle of a thread.. But "end-of-thread"/"end-of-processing" is not identifiable in our case.

@what-the-diff
Copy link

what-the-diff bot commented Mar 22, 2023

PR Summary

  • Improved code reliability Added a safety annotation to the Coordinates.compareTo() method
  • Enhanced resource management Ensured streams are properly closed in DepDirs and UnplaceMojo classes
  • Addressed SonarCloud issues Fixed the unclosed JsonReader object in DcsDepgraph class
  • Resolved resource leaks Fixed issues with unclosed resources in BytesOf.shift(), FtDefault.list(), and Walk.list() functions
  • Fixed stack overflow error Addressed an error caused by a repetitive regular expression (see comments)

@mximp
Copy link
Contributor Author

mximp commented Mar 24, 2023

@yegor256 please check my comment #1930 (comment)

@mximp
Copy link
Contributor Author

mximp commented Mar 27, 2023

@yegor256 reminder

@yegor256
Copy link
Member

yegor256 commented Mar 27, 2023

@rultor merge

@rultor
Copy link
Contributor

rultor commented Mar 27, 2023

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor
Copy link
Contributor

rultor commented Mar 27, 2023

@rultor merge

@mximp @yegor256 Oops, I failed. You can see the full log here (spent 2hr)

+ : __rvm_env_loaded:1:
+ : __rvm_env_loaded:0:
+ [[ -z /usr/local/rvm/tmp ]]
+ ((  __rvm_env_loaded > 0  ))
+ [[ -n 5.1.16(1)-release ]]
+ trap - EXIT HUP INT QUIT TERM
+ [[ -n '' ]]
+ ((  rvm_bash_nounset == 1  ))
+ unset rvm_bash_nounset
+ [[ -n '' ]]
+ [[ -n 0002 ]]
+ umask 0002
+ unset rvm_stored_umask
+ builtin command -v __rvm_cleanup_download
+ [[ '' == \1 ]]
+ __variables_definition unset
+ typeset -a __variables_list __array_list
+ typeset __method
+ __method=unset
+ __variables_list=(rvm_head_flag rvm_ruby_selected_flag rvm_user_install_flag rvm_path_flag rvm_cron_flag rvm_static_flag rvm_default_flag rvm_loaded_flag rvm_llvm_flag rvm_skip_autoreconf_flag rvm_dynamic_extensions_flag rvm_18_flag rvm_19_flag rvm_20_flag rvm_21_flag rvm_force_autoconf_flag rvm_dump_environment_flag rvm_curl_flags rvm_rubygems_version rvm_verbose_flag rvm_debug_flag rvm_trace_flag __array_start rvm_skip_pristine_flag rvm_create_flag rvm_remove_flag rvm_movable_flag rvm_archive_flag rvm_gemdir_flag rvm_reload_flag rvm_auto_reload_flag rvm_disable_binary_flag rvm_ignore_gemsets_flag rvm_skip_gemsets_flag rvm_install_on_use_flag rvm_remote_flag rvm_verify_downloads_flag rvm_skip_openssl_flag rvm_gems_cache_path rvm_gems_path rvm_man_path rvm_ruby_gem_path rvm_ruby_log_path rvm_gems_cache_path rvm_archives_path rvm_docs_path rvm_environments_path rvm_examples_path rvm_gems_path rvm_gemsets_path rvm_help_path rvm_hooks_path rvm_lib_path rvm_log_path rvm_patches_path rvm_repos_path rvm_rubies_path rvm_scripts_path rvm_src_path rvm_tmp_path rvm_user_path rvm_usr_path rvm_wrappers_path rvm_stored_errexit rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_tag rvm_ruby_sha rvm_ruby_repo_tag rvm_ruby_version rvm_ruby_package_file rvm_ruby_name rvm_ruby_name rvm_ruby_args rvm_ruby_user_tag rvm_ruby_patch detected_rvm_ruby_name __rvm_env_loaded next_token rvm_error_message rvm_gemset_name rvm_parse_break rvm_token rvm_action rvm_export_args rvm_gemset_separator rvm_expanding_aliases rvm_tar_command rvm_tar_options rvm_patch_original_pwd rvm_project_rvmrc rvm_archive_extension rvm_autoinstall_bundler_flag rvm_codesign_identity rvm_expected_gemset_name rvm_without_gems rvm_with_gems rvm_with_default_gems rvm_ignore_dotfiles_flag rvm_fuzzy_flag rvm_autolibs_flag rvm_autolibs_flag_number rvm_autolibs_flag_runner rvm_quiet_curl_flag rvm_max_time_flag rvm_error_clr rvm_warn_clr rvm_debug_clr rvm_notify_clr rvm_code_clr rvm_comment_clr rvm_reset_clr rvm_error_color rvm_warn_color rvm_debug_color rvm_notify_color rvm_code_color rvm_comment_color rvm_reset_color rvm_log_timestamp rvm_log_filesystem rvm_log_namelen rvm_show_log_lines_on_error)
+ __array_list=(rvm_patch_names rvm_ree_options rvm_autoconf_flags rvm_architectures)
+ case "${__method}" in
+ unset rvm_patch_names rvm_ree_options rvm_autoconf_flags rvm_architectures
+ unset rvm_head_flag rvm_ruby_selected_flag rvm_user_install_flag rvm_path_flag rvm_cron_flag rvm_static_flag rvm_default_flag rvm_loaded_flag rvm_llvm_flag rvm_skip_autoreconf_flag rvm_dynamic_extensions_flag rvm_18_flag rvm_19_flag rvm_20_flag rvm_21_flag rvm_force_autoconf_flag rvm_dump_environment_flag rvm_curl_flags rvm_rubygems_version rvm_verbose_flag rvm_debug_flag rvm_trace_flag __array_start rvm_skip_pristine_flag rvm_create_flag rvm_remove_flag rvm_movable_flag rvm_archive_flag rvm_gemdir_flag rvm_reload_flag rvm_auto_reload_flag rvm_disable_binary_flag rvm_ignore_gemsets_flag rvm_skip_gemsets_flag rvm_install_on_use_flag rvm_remote_flag rvm_verify_downloads_flag rvm_skip_openssl_flag rvm_gems_cache_path rvm_gems_path rvm_man_path rvm_ruby_gem_path rvm_ruby_log_path rvm_gems_cache_path rvm_archives_path rvm_docs_path rvm_environments_path rvm_examples_path rvm_gems_path rvm_gemsets_path rvm_help_path rvm_hooks_path rvm_lib_path rvm_log_path rvm_patches_path rvm_repos_path rvm_rubies_path rvm_scripts_path rvm_src_path rvm_tmp_path rvm_user_path rvm_usr_path rvm_wrappers_path rvm_stored_errexit rvm_ruby_strings rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_repo_branch rvm_ruby_revision rvm_ruby_tag rvm_ruby_sha rvm_ruby_repo_tag rvm_ruby_version rvm_ruby_package_file rvm_ruby_name rvm_ruby_name rvm_ruby_args rvm_ruby_user_tag rvm_ruby_patch detected_rvm_ruby_name __rvm_env_loaded next_token rvm_error_message rvm_gemset_name rvm_parse_break rvm_token rvm_action rvm_export_args rvm_gemset_separator rvm_expanding_aliases rvm_tar_command rvm_tar_options rvm_patch_original_pwd rvm_project_rvmrc rvm_archive_extension rvm_autoinstall_bundler_flag rvm_codesign_identity rvm_expected_gemset_name rvm_without_gems rvm_with_gems rvm_with_default_gems rvm_ignore_dotfiles_flag rvm_fuzzy_flag rvm_autolibs_flag rvm_autolibs_flag_number rvm_autolibs_flag_runner rvm_quiet_curl_flag rvm_max_time_flag rvm_error_clr rvm_warn_clr rvm_debug_clr rvm_notify_clr rvm_code_clr rvm_comment_clr rvm_reset_clr rvm_error_color rvm_warn_color rvm_debug_color rvm_notify_color rvm_code_color rvm_comment_color rvm_reset_color rvm_log_timestamp rvm_log_filesystem rvm_log_namelen rvm_show_log_lines_on_error
+ [[ -n 5.1.16(1)-release ]]
+ export -fn __rvm_select_version_variables __rvm_ruby_string_parse_ __rvm_rm_rf_verbose __rvm_parse_args __rvm_ruby_string_find __rvm_file_load_env __rvm_remove_without_gems
+ unset _system_arch _system_name _system_type _system_version
+ return 0
+ return 0
+ true
+ latexmk -pdf
Rc files read:
  .latexmkrc
Latexmk: This is Latexmk, John Collins, 7 Jan. 2023. Version 4.79.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Category 'other':
  Rerun of 'pdflatex' forced or previously required

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex  -recorder  --shell-escape "eolang-paper.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
(./eolang-paper.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-02-22>

! LaTeX Error: File `acmart.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Enter file name: 73b60f3a4437482d28d6909f34dd1fa715151fc32dc4a90a110c0e693476783b
'pid' file is absent on the server after the end of operation; it seems that we didn't manage to start Docker container correctly

@pr-codex
Copy link

pr-codex bot commented Mar 30, 2023

Tldr

This PR introduces some improvements, fixes and code refactorings for the eo-maven-plugin and eo-parser.

Detailed summary

  • Fixing org.eolang.maven.Coordinates and org.eolang.maven.DepDirs files to comply with SpotBugs issues.
  • Fixing org.eolang.maven.UnplaceMojo file to comply with Checkstyle issues.
  • Fixing org.eolang.maven.dependencies.DcsDepgraph, org.eolang.maven.footprint.FtDefault, and org.eolang.maven.util.Walk files to comply with SonarCloud issues.
  • Fixing org.eolang.parser.RedundantParentheses file to comply with SonarCloud issues.
  • Fixing org.eolang.BytesOf file to comply with Checkstyle issues.

@mximp
Copy link
Contributor Author

mximp commented Mar 30, 2023

@yegor256 please try again

@yegor256
Copy link
Member

@rultor merge

@rultor
Copy link
Contributor

rultor commented Mar 30, 2023

@rultor merge

@mximp @yegor256 We failed, sorry, try again:

java.lang.ClassCastException: class javax.json.JsonValueImpl cannot be cast to class javax.json.JsonString (javax.json.JsonValueImpl and javax.json.JsonString are in unnamed module of loader 'app')
	at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonString(JsonObjectBuilderImpl.java:252)
	at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getString(JsonObjectBuilderImpl.java:257)
	at com.jcabi.github.RtChecks.check(RtChecks.java:127)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at com.jcabi.github.RtChecks.lambda$all$0(RtChecks.java:113)
	at java.base/java.util.Optional.map(Optional.java:260)
	at com.jcabi.github.RtChecks.all(RtChecks.java:110)
	at com.rultor.agents.github.qtn.QnMerge.allChecksSuccessful(QnMerge.java:185)
	at com.rultor.agents.github.qtn.QnMerge.understand(QnMerge.java:80)
	at com.rultor.agents.github.qtn.QnIfUnlocked.understand(QnIfUnlocked.java:101)
	at com.rultor.agents.github.qtn.QnIfPull.understand(QnIfPull.java:81)
	at com.rultor.agents.github.qtn.QnAskedBy.understand(QnAskedBy.java:105)
	at com.rultor.agents.github.qtn.QnIfContains.understand(QnIfContains.java:79)
	at com.rultor.agents.github.qtn.QnFirstOf.understand(QnFirstOf.java:81)
	at com.rultor.agents.github.qtn.QnByArchitect.understand(QnByArchitect.java:113)
	at com.rultor.agents.github.qtn.QnAlone.understand(QnAlone.java:96)
	at com.rultor.agents.github.qtn.QnIfCollaborator.understand(QnIfCollaborator.java:84)
	at com.rultor.agents.github.qtn.QnFirstOf.understand(QnFirstOf.java:81)
	at com.rultor.agents.github.qtn.QnFollow.understand(QnFollow.java:85)
	at com.rultor.agents.github.qtn.QnWithAuthor.understand(QnWithAuthor.java:72)
	at com.rultor.agents.github.qtn.QnParametrized.understand(QnParametrized.java:89)
	at com.rultor.agents.github.qtn.QnReaction.understand(QnReaction.java:96)
	at com.rultor.agents.github.qtn.QnReferredTo.understand(QnReferredTo.java:104)
	at com.rultor.agents.github.qtn.QnNotSelf.understand(QnNotSelf.java:75)
	at com.rultor.agents.github.qtn.QnSince.understand(QnSince.java:79)
	at com.rultor.agents.github.qtn.QnSafe.understand(QnSafe.java:82)
	at com.rultor.agents.github.Understands.parse(Understands.java:197)
	at com.rultor.agents.github.Understands.process(Understands.java:131)
	at com.rultor.agents.AbstractAgent.execute(AbstractAgent.java:70)
	at com.rultor.spi.Agent$Iterative.execute(Agent.java:84)
	at com.rultor.Routine.process(Routine.java:202)
	at com.rultor.Routine.unsafe_aroundBody0(Routine.java:180)
	at com.rultor.Routine$AjcClosure1.run(Routine.java:1)
	at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:179)
	at com.jcabi.aspects.aj.MethodInterrupter.wrap(MethodInterrupter.java:108)
	at com.rultor.Routine.unsafe(Routine.java:175)
	at com.rultor.Routine.run(Routine.java:142)
	at com.jcabi.log.VerboseRunnable.run(VerboseRunnable.java:190)
	at com.jcabi.aspects.aj.MethodScheduler$Service.lambda$0(MethodScheduler.java:194)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at com.jcabi.log.VerboseThreads$Wrap.run(VerboseThreads.java:222)
	at java.base/java.lang.Thread.run(Thread.java:833)

@mximp
Copy link
Contributor Author

mximp commented Mar 31, 2023

@yegor256 please merge

@yegor256
Copy link
Member

@rultor merge

@rultor
Copy link
Contributor

rultor commented Mar 31, 2023

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 8e82e61 into objectionary:master Mar 31, 2023
@rultor
Copy link
Contributor

rultor commented Mar 31, 2023

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 7min)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants