Skip to content

Commit

Permalink
Do not write output files if REPORT_OUTPUT_FOLDER is none (#2213)
Browse files Browse the repository at this point in the history
* Do not write output files if REPORT_OUTPUT_FOLDER is none

Fixes #2108

* [MegaLinter] Apply linters fixes

Co-authored-by: nvuillam <nvuillam@users.noreply.github.com>
  • Loading branch information
nvuillam and nvuillam authored Jan 3, 2023
1 parent f74ae13 commit 1688acf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ Configuration is assisted with auto-completion and validation in most commonly u
| [**PRE_COMMANDS**](#pre-commands) | \[\] | Custom bash commands to run before linters |
| **PRINT_ALPACA** | `true` | Enable printing alpaca image to console |
| **PRINT_ALL_FILES** | `false` | Display all files analyzed by the linter instead of only the number |
| **REPORT_OUTPUT_FOLDER** | `${GITHUB_WORKSPACE}/megalinter-reports` | Directory for generating report files. Send `none` to not generate reports |
| **REPORT_OUTPUT_FOLDER** | `${GITHUB_WORKSPACE}/megalinter-reports` | Directory for generating report files. Set to `none` to not generate reports |
| **SHOW_ELAPSED_TIME** | `false` | Displays elapsed time in reports |
| **SHOW_SKIPPED_LINTERS** | `true` | Displays all disabled linters mega-linter could have run |
| **SKIP_CLI_LINT_MODES** | \[\] | Comma-separated list of cli_lint_modes. To use if you want to skip linters with some CLI lint modes (ex: `file,project`). Available values: `file`,`cli_lint_mode`,`project`. |
Expand Down
13 changes: 9 additions & 4 deletions megalinter/MegaLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,10 @@ def initialize_logger(self):
if logging_level_key in logging_level_list
else logging.INFO
)
log_file = (
self.report_folder + os.path.sep + config.get("LOG_FILE", "megalinter.log")
)
if config.get("LOG_FILE", "") == "none":

if config.get("LOG_FILE", "") == "none" or not utils.can_write_report_files(
self
):
# Do not log console output in a file
logging.basicConfig(
force=True,
Expand All @@ -775,6 +775,11 @@ def initialize_logger(self):
],
)
else:
log_file = (
self.report_folder
+ os.path.sep
+ config.get("LOG_FILE", "megalinter.log")
)
# Log console output in a file
if not os.path.isdir(os.path.dirname(log_file)):
os.makedirs(os.path.dirname(log_file), exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion megalinter/linters/CSpellLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def execute_lint_command(self, command):
# noinspection PyMethodMayBeStatic
def complete_text_reporter_report(self, reporter_self):
# Collect detected words from logs
if self.stdout is None:
if self.stdout is None or not utils.can_write_report_files(self.master):
return []
whitelisted_words = []
for log_line in self.stdout.split("\n"):
Expand Down

0 comments on commit 1688acf

Please sign in to comment.