Skip to content

Commit b2173f6

Browse files
committed
Added config option to use a list of absolute file paths that can only be used for the source scan, fixed a small issue with rendering nodes without modularity
1 parent ac4dbf1 commit b2173f6

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ The yaml configuration is basically defined at the following levels:
467467
| `ignore_directories_containing` | exclude directory names from the scan that contain the given substrings |
468468
| `only_permit_languages` | possible values include: java, kotlin, objc, swift, ruby, groovy, javascript, c - explicitly prevents any other language from scanning besides the one you set here |
469469
| `only_permit_file_extensions` | explicitly permit the following file extensions you set here, e.g. `.java` |
470+
| `only_permit_files_matching_absolute_path` | only the following list of absolute file paths is permitted for the file scan, e.g. `/Users/user1/source/file1.java` |
470471
| `ignore_dependencies_containing` | ignore every dependency included in this list of substrings, e.g. `java.util` |
471-
| `import_aliases` | define import aliases, i.e. replace substrings within a full dependency path, e.g. `- "@foo": src/foo` will replace any `@foo` alias by `src/foo` |
472+
| `import_aliases` | define a list of import aliases, i.e. replace substrings within a full dependency path, e.g. `"@foo": src/foo` will replace any `@foo` alias by `src/foo` |
472473
| `file_scan` | perform a file scan, contains the metrics that should be applied on every source file |
473474
| `entity_scan` | perform an entity scan, contains the metrics that should be applied on every entity (e.g. on every class) |
474475
| `export` | contains any export formats that should be create as output |

emerge/analysis.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def __init__(self):
5656

5757
self.only_permit_languages: List[LanguageType] = []
5858
self.only_permit_file_extensions: List[str] = []
59+
self.only_permit_files_matching_absolute_path_available: bool = False
60+
self.only_permit_files_matching_absolute_path: List[str] = []
5961
self.ignore_directories_containing: List = []
6062
self.ignore_files_containing: List = []
6163
self.ignore_dependencies_containing: List[str] = []
@@ -406,6 +408,7 @@ def create_filesystem_graph(self) -> None:
406408

407409
for root, dirs, files in os.walk(self.source_directory):
408410
# exclude directories and scans
411+
409412
if self.ignore_directories_containing:
410413
dirs[:] = [d for d in dirs if d not in self.ignore_directories_containing]
411414

@@ -436,6 +439,15 @@ def create_filesystem_graph(self) -> None:
436439
for file_name in files:
437440
absolute_path_to_file = os.path.join(root, file_name)
438441

442+
# check if the scan should only allow specific files
443+
if self.only_permit_files_matching_absolute_path_available:
444+
if absolute_path_to_file not in self.only_permit_files_matching_absolute_path:
445+
skipped_files += 1
446+
LOGGER.info(f'ignoring file {absolute_path_to_file} due to only_scan_files restriction')
447+
continue
448+
else:
449+
LOGGER.info(f'got file {absolute_path_to_file}')
450+
439451
# watch out for symlinks
440452
if os.path.islink(absolute_path_to_file):
441453
LOGGER.debug(f'possible symlink found: {absolute_path_to_file}')

emerge/appear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
coloredlogs.install(level='E', logger=LOGGER.logger(), fmt=Logger.log_format)
3333

3434
__version__ = '1.2.1'
35-
__updated__ = '2022-04-24 20:45:08'
35+
__updated__ = '2022-04-25 21:11:53'
3636

3737

3838
class Emerge:

emerge/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ConfigKeyAnalysis(EnumKeyValid, Enum):
6767
SOURCE_DIRECTORY = auto()
6868
ONLY_PERMIT_LANGUAGES = auto()
6969
ONLY_PERMIT_FILE_EXTENSIONS = auto()
70+
ONLY_PERMIT_FILES_MATCHING_ABSOLUTE_PATH = auto()
7071
IGNORE_DIRECTORIES_CONTAINING = auto()
7172
IGNORE_FILES_CONTAINING = auto()
7273
IGNORE_DEPENDENCIES_CONTAINING = auto()
@@ -421,6 +422,13 @@ def _update_attributes_from_yaml_config(self):
421422
analysis.import_aliases_available = True
422423
analysis.import_aliases[dependency_substring] = replaced_dependency_substring
423424

425+
# check if the analysis should only consider specified files
426+
if ConfigKeyAnalysis.ONLY_PERMIT_FILES_MATCHING_ABSOLUTE_PATH.name.lower() in analysis_dict:
427+
for file in analysis_dict[ConfigKeyAnalysis.ONLY_PERMIT_FILES_MATCHING_ABSOLUTE_PATH.name.lower()]:
428+
if analysis.only_permit_files_matching_absolute_path_available == False:
429+
analysis.only_permit_files_matching_absolute_path_available = True
430+
analysis.only_permit_files_matching_absolute_path.append(file)
431+
424432
# load metrics from analysis
425433
if ConfigKeyAnalysis.FILE_SCAN.name.lower() in analysis_dict:
426434
# add all configured file_scan metrics

emerge/output/html/emerge.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h6 class="card-header">
9090
<path d="M2 1a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM0 2a2 2 0 0 1 3.937-.5h8.126A2 2 0 1 1 14.5 3.937v8.126a2 2 0 1 1-2.437 2.437H3.937A2 2 0 1 1 1.5 12.063V3.937A2 2 0 0 1 0 2zm2.5 1.937v8.126c.703.18 1.256.734 1.437 1.437h8.126a2.004 2.004 0 0 1 1.437-1.437V3.937A2.004 2.004 0 0 1 12.063 2.5H3.937A2.004 2.004 0 0 1 2.5 3.937zM14 1a1 1 0 1 0 0 2 1 1 0 0 0 0-2zM2 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm12 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
9191
</svg>
9292
<span>
93-
<small>Emerge v1.2.0</small>
93+
<small>Emerge v1.2.1</small>
9494
</span>
9595
</span>
9696
</h6>
@@ -380,6 +380,7 @@ <h5 class="modal-title" id="overallMetricsModalLabel">Overall metrics</h5>
380380
const activeSelectionColor = '#FF0000'
381381
const directoryNodeColor = '#3b8cff'
382382
const fileNodeColor = '#d1e3ff'
383+
const defaultNodeColor = '#1f77b4'
383384

384385
/**
385386
* * MARK: - Math constants
@@ -952,6 +953,8 @@ <h5 class="modal-title" id="overallMetricsModalLabel">Overall metrics</h5>
952953
}
953954
}
954955
}
956+
957+
return hexToRGB(defaultNodeColor)
955958
}
956959

957960
function setInitialDarkMode() {

0 commit comments

Comments
 (0)