5
5
import org .jetbrains .annotations .NotNull ;
6
6
import org .jetbrains .annotations .Nullable ;
7
7
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 .*;
15
9
import java .util .stream .Collectors ;
16
10
17
11
public abstract class DeepCodeUtilsBase {
@@ -23,11 +17,11 @@ public abstract class DeepCodeUtilsBase {
23
17
private final DCLoggerBase dcLogger ;
24
18
25
19
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 ) {
31
25
this .analysisData = analysisData ;
32
26
this .deepCodeParams = deepCodeParams ;
33
27
this .ignoreInfoHolder = ignoreInfoHolder ;
@@ -40,7 +34,7 @@ protected DeepCodeUtilsBase(
40
34
protected static Set <String > supportedConfigFiles = Collections .emptySet ();
41
35
42
36
public List <Object > getAllSupportedFilesInProject (
43
- @ NotNull Object project , boolean scanAllMissedIgnoreFile , @ Nullable Object progress ) {
37
+ @ NotNull Object project , boolean scanAllMissedIgnoreFile , @ Nullable Object progress ) {
44
38
final Collection <Object > allProjectFiles = allProjectFiles (project );
45
39
if (allProjectFiles .isEmpty ()) {
46
40
dcLogger .logWarn ("Empty files list for project: " + project );
@@ -55,7 +49,7 @@ public List<Object> getAllSupportedFilesInProject(
55
49
final List <Object > result = new ArrayList <>();
56
50
for (Object file : allProjectFiles ) {
57
51
pdUtils .progressSetText (
58
- progress , "Checked if supported " + counter + " files of " + totalSize );
52
+ progress , "Checked if supported " + counter + " files of " + totalSize );
59
53
pdUtils .progressSetFraction (progress , ((double ) counter ++ / totalSize ));
60
54
if (isSupportedFileFormat (file )) {
61
55
result .add (file );
@@ -77,12 +71,11 @@ public List<Object> getAllSupportedFilesInProject(
77
71
public boolean isSupportedFileFormat (@ NotNull Object file ) {
78
72
// DCLogger.getInstance().info("isSupportedFileFormat started for " + psiFile.getName());
79
73
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 )));
84
77
// DCLogger.getInstance().info("isSupportedFileFormat ends for " + psiFile.getName());
85
- return result ;
78
+ return supported ;
86
79
}
87
80
88
81
protected abstract long getFileLength (@ NotNull Object file );
@@ -91,41 +84,43 @@ public boolean isSupportedFileFormat(@NotNull Object file) {
91
84
92
85
protected abstract boolean isGitIgnoredExternalCheck (@ NotNull Object file );
93
86
94
- /** Potentially <b>Heavy</b> network request! */
87
+ /**
88
+ * Potentially <b>Heavy</b> network request!
89
+ */
95
90
private void initSupportedExtentionsAndConfigFiles () {
96
91
GetFiltersResponse filtersResponse =
97
- DeepCodeRestApi .getFilters (deepCodeParams .getSessionToken ());
92
+ DeepCodeRestApi .getFilters (deepCodeParams .getSessionToken ());
98
93
if (filtersResponse .getStatusCode () == 200 ) {
99
94
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 ());
103
98
supportedConfigFiles = new HashSet <>(filtersResponse .getConfigFiles ());
104
99
dcLogger .logInfo ("Supported extensions: " + supportedExtensions );
105
100
dcLogger .logInfo ("Supported configFiles: " + supportedConfigFiles );
106
101
} else {
107
102
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 ());
112
107
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" ));
117
112
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" ));
129
124
}
130
125
}
131
126
0 commit comments