Skip to content

Commit a4eb004

Browse files
committed
Refactor MoodleSettingsForm to improve inspection profile management and update bundled inspection profile settings.
1 parent f6128f3 commit a4eb004

3 files changed

Lines changed: 56 additions & 48 deletions

File tree

src/main/kotlin/il/co/sysbind/intellij/moodledev/project/MoodleSettingsForm.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.intellij.openapi.options.ShowSettingsUtil
1212
import com.intellij.openapi.project.Project
1313
import com.intellij.openapi.project.guessProjectDir
1414
import com.intellij.openapi.ui.TextFieldWithBrowseButton
15-
import com.intellij.profile.codeInspection.InspectionProjectProfileManager
15+
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager
1616
import com.intellij.ui.components.JBCheckBox
1717
import com.intellij.ui.dsl.builder.*
1818
import com.jetbrains.php.config.interpreters.PhpInterpretersManagerImpl
@@ -123,13 +123,14 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
123123
val optionsConfig = PhpCSOptionsConfiguration.getInstance(project)
124124
optionsConfig.isShowSniffs = true
125125
optionsConfig.codingStandard = "moodle"
126+
optionsConfig.extensions = "php"
126127

127128
// Enable PhpCSValidationInspection
128-
val profileManager = InspectionProjectProfileManager.getInstance(project)
129-
val profile = profileManager.currentProfile
130-
profile.setToolEnabled("PhpCSValidationInspection", true)
131-
log.info("Successfully enabled PhpCSValidationInspection")
129+
val profileManager = ProjectInspectionProfileManager.getInstance(project)
130+
profileManager.useApplicationProfile("Moodle")
131+
profileManager.fireProfileChanged()
132132

133+
log.info("Successfully enabled PhpCSValidationInspection")
133134
// Try to set the configuration for phpcs_by_interpreter
134135
try {
135136
manager.markAndSetNewSettings(listOf(configuration))

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
implementation="il.co.sysbind.intellij.moodledev.codeStyle.MoodleJavascriptPredefinedCodeStyle"/>
3939
<predefinedCodeStyle implementation="il.co.sysbind.intellij.moodledev.codeStyle.MoodleLessPredefinedCodeStyle"/>
4040
<predefinedCodeStyle implementation="il.co.sysbind.intellij.moodledev.codeStyle.MoodleScssPredefinedCodeStyle"/>
41-
<bundledInspectionProfile path="/inspectionProfiles/Moodle" id="Moodle.InspecProfile"/>
41+
<bundledInspectionProfile path="/inspectionProfiles/Moodle" id="Moodle.InspectProfile"/>
4242

4343
<internalFileTemplate name="Moodle PHP File"/>
4444
<internalFileTemplate name="Moodle PHP Class"/>
Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,53 @@
1-
<component name="InspectionProjectProfileManager">
2-
<profile version="1.0">
3-
<option name="myName" value="Moodle" />
4-
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5-
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
6-
<inspection_tool class="PhpCSValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
7-
<inspection_tool class="PhpClassNamingConventionInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
8-
<option name="m_regex" value="[a-z][_a-z\d]*" />
9-
<option name="m_minLength" value="0" />
10-
<option name="m_maxLength" value="132" />
11-
</inspection_tool>
12-
<inspection_tool class="PhpConstantNamingConventionInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
13-
<option name="m_minLength" value="0" />
14-
<option name="m_maxLength" value="132" />
15-
</inspection_tool>
16-
<inspection_tool class="PhpDocMissingThrowsInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
17-
<inspection_tool class="PhpEnforceDocCommentInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
18-
<option name="CHECK_CONSTANT" value="true" />
19-
<option name="CHECK_FIELD" value="true" />
20-
<option name="CHECK_CLASS_CONSTANT" value="true" />
21-
</inspection_tool>
22-
<inspection_tool class="PhpFunctionNamingConventionInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
23-
<option name="m_minLength" value="0" />
24-
<option name="m_maxLength" value="132" />
25-
</inspection_tool>
26-
<inspection_tool class="PhpMethodNamingConventionInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
27-
<option name="m_regex" value="[a-z][_a-z\d]*" />
28-
<option name="m_minLength" value="0" />
29-
<option name="m_maxLength" value="132" />
30-
</inspection_tool>
31-
<inspection_tool class="PhpPropertyNamingConventionInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
32-
<option name="m_regex" value="[a-z][a-z\d]*" />
33-
<option name="m_minLength" value="0" />
34-
<option name="m_maxLength" value="132" />
1+
<profile version="1.0">
2+
<description>Moodle Code Inspections</description>
3+
<option name="myName" value="Moodle"/>
4+
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true"/>
5+
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true"/>
6+
<inspection_tool class="PhpCSValidationInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true"/>
7+
<inspection_tool class="PhpClassNamingConventionInspection" enabled="true" level="WEAK WARNING"
8+
enabled_by_default="true">
9+
<option name="m_regex" value="[a-z][_a-z\d]*"/>
10+
<option name="m_minLength" value="0"/>
11+
<option name="m_maxLength" value="132"/>
12+
</inspection_tool>
13+
<inspection_tool class="PhpConstantNamingConventionInspection" enabled="true" level="WEAK WARNING"
14+
enabled_by_default="true">
15+
<option name="m_minLength" value="0"/>
16+
<option name="m_maxLength" value="132"/>
17+
</inspection_tool>
18+
<inspection_tool class="PhpDocMissingThrowsInspection" enabled="false" level="WEAK WARNING"
19+
enabled_by_default="false"/>
20+
<inspection_tool class="PhpEnforceDocCommentInspection" enabled="true" level="WEAK WARNING"
21+
enabled_by_default="true">
22+
<option name="CHECK_CONSTANT" value="true"/>
23+
<option name="CHECK_FIELD" value="true"/>
24+
<option name="CHECK_CLASS_CONSTANT" value="true"/>
25+
</inspection_tool>
26+
<inspection_tool class="PhpFunctionNamingConventionInspection" enabled="true" level="WEAK WARNING"
27+
enabled_by_default="true">
28+
<option name="m_minLength" value="0"/>
29+
<option name="m_maxLength" value="132"/>
30+
</inspection_tool>
31+
<inspection_tool class="PhpMethodNamingConventionInspection" enabled="true" level="WEAK WARNING"
32+
enabled_by_default="true">
33+
<option name="m_regex" value="[a-z][_a-z\d]*"/>
34+
<option name="m_minLength" value="0"/>
35+
<option name="m_maxLength" value="132"/>
36+
</inspection_tool>
37+
<inspection_tool class="PhpPropertyNamingConventionInspection" enabled="true" level="WEAK WARNING"
38+
enabled_by_default="true">
39+
<option name="m_regex" value="[a-z][a-z\d]*"/>
40+
<option name="m_minLength" value="0"/>
41+
<option name="m_maxLength" value="132"/>
3542
</inspection_tool>
3643
<inspection_tool class="PhpUndefinedVariableInspection" enabled="true" level="ERROR" enabled_by_default="true">
37-
<option name="IGNORE_INCLUDE" value="true" />
44+
<option name="IGNORE_INCLUDE" value="true"/>
3845
</inspection_tool>
39-
<inspection_tool class="PhpVariableNamingConventionInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
40-
<option name="m_regex" value="^(CFG|SESSION|USER|COURSE|SITE|PAGE|PERF|DB|THEME|OUTPUT|[a-z][a-z\d]*)$" />
41-
<option name="m_minLength" value="0" />
42-
<option name="m_maxLength" value="132" />
46+
<inspection_tool class="PhpVariableNamingConventionInspection" enabled="true" level="WEAK WARNING"
47+
enabled_by_default="true">
48+
<option name="m_regex" value="^(CFG|SESSION|USER|COURSE|SITE|PAGE|PERF|DB|THEME|OUTPUT|[a-z][a-z\d]*)$"/>
49+
<option name="m_minLength" value="0"/>
50+
<option name="m_maxLength" value="132"/>
4351
</inspection_tool>
44-
<inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
45-
</profile>
46-
</component>
52+
<inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true"/>
53+
</profile>

0 commit comments

Comments
 (0)