55import org .jetbrains .annotations .NotNull ;
66import org .jetbrains .annotations .Nullable ;
77
8- import java .util .ArrayList ;
9- import java .util .Arrays ;
10- import java .util .Collection ;
11- import java .util .Collections ;
12- import java .util .HashSet ;
13- import java .util .List ;
14- import java .util .Set ;
8+ import java .util .*;
159import java .util .stream .Collectors ;
1610
1711public abstract class DeepCodeUtilsBase {
@@ -23,11 +17,11 @@ public abstract class DeepCodeUtilsBase {
2317 private final DCLoggerBase dcLogger ;
2418
2519 protected DeepCodeUtilsBase (
26- @ NotNull AnalysisDataBase analysisData ,
27- @ NotNull DeepCodeParamsBase deepCodeParams ,
28- @ NotNull DeepCodeIgnoreInfoHolderBase ignoreInfoHolder ,
29- @ NotNull PlatformDependentUtilsBase pdUtils ,
30- @ NotNull DCLoggerBase dcLogger ) {
20+ @ NotNull AnalysisDataBase analysisData ,
21+ @ NotNull DeepCodeParamsBase deepCodeParams ,
22+ @ NotNull DeepCodeIgnoreInfoHolderBase ignoreInfoHolder ,
23+ @ NotNull PlatformDependentUtilsBase pdUtils ,
24+ @ NotNull DCLoggerBase dcLogger ) {
3125 this .analysisData = analysisData ;
3226 this .deepCodeParams = deepCodeParams ;
3327 this .ignoreInfoHolder = ignoreInfoHolder ;
@@ -40,7 +34,7 @@ protected DeepCodeUtilsBase(
4034 protected static Set <String > supportedConfigFiles = Collections .emptySet ();
4135
4236 public List <Object > getAllSupportedFilesInProject (
43- @ NotNull Object project , boolean scanAllMissedIgnoreFile , @ Nullable Object progress ) {
37+ @ NotNull Object project , boolean scanAllMissedIgnoreFile , @ Nullable Object progress ) {
4438 final Collection <Object > allProjectFiles = allProjectFiles (project );
4539 if (allProjectFiles .isEmpty ()) {
4640 dcLogger .logWarn ("Empty files list for project: " + project );
@@ -55,7 +49,7 @@ public List<Object> getAllSupportedFilesInProject(
5549 final List <Object > result = new ArrayList <>();
5650 for (Object file : allProjectFiles ) {
5751 pdUtils .progressSetText (
58- progress , "Checked if supported " + counter + " files of " + totalSize );
52+ progress , "Checked if supported " + counter + " files of " + totalSize );
5953 pdUtils .progressSetFraction (progress , ((double ) counter ++ / totalSize ));
6054 if (isSupportedFileFormat (file )) {
6155 result .add (file );
@@ -77,12 +71,11 @@ public List<Object> getAllSupportedFilesInProject(
7771 public boolean isSupportedFileFormat (@ NotNull Object file ) {
7872 // DCLogger.getInstance().info("isSupportedFileFormat started for " + psiFile.getName());
7973 if (ignoreInfoHolder .isIgnoredFile (file ) || isGitIgnoredExternalCheck (file )) return false ;
80- final boolean result =
81- getFileLength (file ) < MAX_FILE_SIZE
82- && (supportedExtensions .contains (getFileExtention (file ))
83- || supportedConfigFiles .contains (pdUtils .getFileName (file )));
74+ long fileLength = getFileLength (file );
75+ boolean supported = 0 < fileLength && fileLength < MAX_FILE_SIZE &&
76+ (supportedExtensions .contains (getFileExtention (file )) || supportedConfigFiles .contains (pdUtils .getFileName (file )));
8477 // DCLogger.getInstance().info("isSupportedFileFormat ends for " + psiFile.getName());
85- return result ;
78+ return supported ;
8679 }
8780
8881 protected abstract long getFileLength (@ NotNull Object file );
@@ -91,41 +84,43 @@ public boolean isSupportedFileFormat(@NotNull Object file) {
9184
9285 protected abstract boolean isGitIgnoredExternalCheck (@ NotNull Object file );
9386
94- /** Potentially <b>Heavy</b> network request! */
87+ /**
88+ * Potentially <b>Heavy</b> network request!
89+ */
9590 private void initSupportedExtentionsAndConfigFiles () {
9691 GetFiltersResponse filtersResponse =
97- DeepCodeRestApi .getFilters (deepCodeParams .getSessionToken ());
92+ DeepCodeRestApi .getFilters (deepCodeParams .getSessionToken ());
9893 if (filtersResponse .getStatusCode () == 200 ) {
9994 supportedExtensions =
100- filtersResponse .getExtensions ().stream ()
101- .map (s -> s .substring (1 )) // remove preceding `.` (`.js` -> `js`)
102- .collect (Collectors .toSet ());
95+ filtersResponse .getExtensions ().stream ()
96+ .map (s -> s .substring (1 )) // remove preceding `.` (`.js` -> `js`)
97+ .collect (Collectors .toSet ());
10398 supportedConfigFiles = new HashSet <>(filtersResponse .getConfigFiles ());
10499 dcLogger .logInfo ("Supported extensions: " + supportedExtensions );
105100 dcLogger .logInfo ("Supported configFiles: " + supportedConfigFiles );
106101 } else {
107102 dcLogger .logWarn (
108- "Can't retrieve supported file extensions and config files from the server. Fallback to default set.\n "
109- + filtersResponse .getStatusCode ()
110- + " "
111- + filtersResponse .getStatusDescription ());
103+ "Can't retrieve supported file extensions and config files from the server. Fallback to default set.\n "
104+ + filtersResponse .getStatusCode ()
105+ + " "
106+ + filtersResponse .getStatusDescription ());
112107 supportedExtensions =
113- new HashSet <>(
114- Arrays .asList (
115- "cc" , "htm" , "cpp" , "cxx" , "c" , "vue" , "h" , "hpp" , "hxx" , "es6" , "js" , "py" , "es" ,
116- "jsx" , "java" , "tsx" , "html" , "ts" ));
108+ new HashSet <>(
109+ Arrays .asList (
110+ "cc" , "htm" , "cpp" , "cxx" , "c" , "vue" , "h" , "hpp" , "hxx" , "es6" , "js" , "py" , "es" ,
111+ "jsx" , "java" , "tsx" , "html" , "ts" ));
117112 supportedConfigFiles =
118- new HashSet <>(
119- Arrays .asList (
120- "pylintrc" ,
121- "ruleset.xml" ,
122- ".eslintrc.json" ,
123- ".pylintrc" ,
124- ".eslintrc.js" ,
125- "tslint.json" ,
126- ".pmdrc.xml" ,
127- ".ruleset.xml" ,
128- ".eslintrc.yml" ));
113+ new HashSet <>(
114+ Arrays .asList (
115+ "pylintrc" ,
116+ "ruleset.xml" ,
117+ ".eslintrc.json" ,
118+ ".pylintrc" ,
119+ ".eslintrc.js" ,
120+ "tslint.json" ,
121+ ".pmdrc.xml" ,
122+ ".ruleset.xml" ,
123+ ".eslintrc.yml" ));
129124 }
130125 }
131126
0 commit comments