diff --git a/docs/cli.html b/docs/cli.html
index ff51d6f8..91913655 100644
--- a/docs/cli.html
+++ b/docs/cli.html
@@ -95,6 +95,58 @@
Project mode
directories/files you're responsible for.
+
+ Please note that MISS_HIT will
not consider files and
+ directories that would be invisible to MATLAB in project
+ mode. Consider for example a projet layout like this:
+
+ /
+ miss_hit.cfg
+ file1.m
+ foo/
+ file2.m
+ +bar/
+ file3.m
+
+
+
+
+ The configuration file contains the following information:
+
entrypoint "Potato" {}
+
+
+
+ When running MISS_HIT without project mode, all files are
+ considered. However, when running MISS_HIT in project mode,
+ only files file1.m and file3.m are
+ considered. File file2.m is not considered because
+ directory foo is not on the path, as declared in our
+ entrypoint.
+
+
+
+ If you want to include
file2.m in your analysis, then
+ you have to include that directory in your entry point, like
+ so:
+
+entrypoint "Potato" {
+ paths {
+ ".",
+ "foo"
+ }
+}
+
+
+
+
+ This behaviour is consistent with how MATLAB deals with its
+ search path. For more information consult:
+
+
+
Common options
All MISS_HIT tools (except mh_diff) have these options. Some
diff --git a/miss_hit_core/command_line.py b/miss_hit_core/command_line.py
index 4b3b46c8..a5ce07be 100644
--- a/miss_hit_core/command_line.py
+++ b/miss_hit_core/command_line.py
@@ -221,30 +221,50 @@ def execute(mh, options, extra_options, back_end, process_slx=True):
"not exist." %
options.entry_point)
+ # Get PATH
+ item_list = n_ep.get_path()
+
if options.debug_show_path:
print("Using the following PATH:")
- for path in n_ep.get_path():
+ for path in item_list:
print("> %s" % os.path.relpath(path))
- item_list = n_ep.get_path()
-
- # If the user has supplied files/dirs to analyze, we only
- # do that if they are part of _this_ entrypoint.
- if options.files:
- items_in_path = set()
- for path_root in item_list:
- for path, _, files in os.walk(path_root):
- items_in_path.add(os.path.normpath(path))
- for f in files:
- items_in_path.add(
+ # Determine relevant files based on these
+ # directories. This is a bit more complex than
+ # "everything".
+ #
+ # See
+ # https://www.mathworks.com/help/matlab/matlab_env/files-and-folders-that-matlab-accesses.html
+
+ items_in_path = set()
+ files_in_path = set()
+ for path_root in item_list:
+ for path, dirs, files in os.walk(path_root):
+ items_in_path.add(os.path.normpath(path))
+ for f in files:
+ if f.endswith(".m") or f.endswith(".slx"):
+ files_in_path.add(
os.path.normpath(os.path.join(path, f)))
+ irrelevant_dirs = set(d for d in dirs
+ if not (d.startswith("+") or
+ d.startswith("@")))
+ for idir in irrelevant_dirs:
+ dirs.remove(idir)
+ items_in_path |= files_in_path
+ if options.files:
+ # If the user has supplied files/dirs to analyze, we
+ # only do that if they are part of _this_ entrypoint.
item_list = list(options.files)
for item in item_list:
if os.path.abspath(item) not in items_in_path:
mh.command_line_error("'%s' is not part of "
"entry point %s" %
(item, options.entry_point))
+ else:
+ # Otherwise we look at all applicable files on the
+ # path.
+ item_list = list(sorted(files_in_path))
else:
# Without an entry point, we build a minimally sufficient
diff --git a/tests/projects/irrelevant/+good/good.m b/tests/projects/irrelevant/+good/good.m
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/projects/irrelevant/+good/irrelevant/bad.m b/tests/projects/irrelevant/+good/irrelevant/bad.m
new file mode 100644
index 00000000..999bcf60
--- /dev/null
+++ b/tests/projects/irrelevant/+good/irrelevant/bad.m
@@ -0,0 +1 @@
+if just ++ not ++ matlab
diff --git a/tests/projects/irrelevant/@thing/irrelevant/bad.m b/tests/projects/irrelevant/@thing/irrelevant/bad.m
new file mode 100644
index 00000000..999bcf60
--- /dev/null
+++ b/tests/projects/irrelevant/@thing/irrelevant/bad.m
@@ -0,0 +1 @@
+if just ++ not ++ matlab
diff --git a/tests/projects/irrelevant/@thing/thing.m b/tests/projects/irrelevant/@thing/thing.m
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/projects/irrelevant/README.md b/tests/projects/irrelevant/README.md
new file mode 100644
index 00000000..ed39c3e4
--- /dev/null
+++ b/tests/projects/irrelevant/README.md
@@ -0,0 +1,9 @@
+When using an entry-point, we should not pick up files from our path
+that MATLAB wouldn't pick up either.
+
+See:
+* https://www.mathworks.com/help/matlab/matlab_env/files-and-folders-that-matlab-accesses.html
+* https://www.mathworks.com/help/matlab/matlab_oop/organizing-classes-in-folders.html
+
+Specifically if a subdirectory not starting with + or @ is in a
+directory on the path, we do not consider it.
diff --git a/tests/projects/irrelevant/cmdline b/tests/projects/irrelevant/cmdline
new file mode 100644
index 00000000..d2f75a08
--- /dev/null
+++ b/tests/projects/irrelevant/cmdline
@@ -0,0 +1 @@
+--entry-point=potato
diff --git a/tests/projects/irrelevant/irrelevant/bad.m b/tests/projects/irrelevant/irrelevant/bad.m
new file mode 100644
index 00000000..999bcf60
--- /dev/null
+++ b/tests/projects/irrelevant/irrelevant/bad.m
@@ -0,0 +1 @@
+if just ++ not ++ matlab
diff --git a/tests/projects/irrelevant/miss_hit.cfg b/tests/projects/irrelevant/miss_hit.cfg
new file mode 100644
index 00000000..3772f555
--- /dev/null
+++ b/tests/projects/irrelevant/miss_hit.cfg
@@ -0,0 +1,3 @@
+project_root
+
+entrypoint "potato" {}
diff --git a/tests/projects/irrelevant/output.txt b/tests/projects/irrelevant/output.txt
new file mode 100644
index 00000000..004a7348
--- /dev/null
+++ b/tests/projects/irrelevant/output.txt
@@ -0,0 +1,11 @@
+=== STYLE ===
+MISS_HIT Style Summary: 2 file(s) analysed, everything seems fine
+=== LINT ===
+MISS_HIT Lint Summary: 2 file(s) analysed, everything seems fine
+=== METRICS ===
+=== Code metric by file:
+
+* Code metrics for file /home/flosch/miss_hit/tests/projects/irrelevant/+good/good.m:
+
+* Code metrics for file /home/flosch/miss_hit/tests/projects/irrelevant/@thing/thing.m:
+MISS_HIT Metric Summary: 2 file(s) analysed, everything seems fine