Skip to content

Commit

Permalink
Fix quality warnings (#86)
Browse files Browse the repository at this point in the history
* Delete unused constructor from SpectralException

* Turn SpectralRunner into a light service by specifying it to run on project level

* Turn ProjectSettingsState into light service

* Format code

* Add changelog and bump version
  • Loading branch information
markbrockhoff authored Aug 2, 2023
1 parent 1b3d645 commit 8397c17
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

## [Unreleased]

### Changed
- Delete unused constructor from SpectralException
- Turn SpectralRunner into a light service
- Turn ProjectSettingsState into a light service
- Reformat code

## [2.1.0] - 2023-08-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pluginGroup=com.schwarzit.spectral-intellij-plugin
pluginName=Spectral
pluginRepositoryUrl=https://github.com/SchwarzIT/spectral-intellij-plugin
# SemVer format -> https://semver.org
pluginVersion=2.1.0
pluginVersion=2.1.1
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild=222
#pluginUntilBuild=231.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ package com.schwarzit.spectralIntellijPlugin

class SpectralException : Exception {
constructor(message: String) : super(message)
constructor(cause: Throwable) : super(cause)
constructor(message: String, cause: Throwable) : super(message, cause)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import org.jetbrains.yaml.psi.YAMLFile
import java.nio.file.FileSystems
import java.nio.file.Paths

class SpectralExternalAnnotator : ExternalAnnotator<Pair<PsiFile,Editor>, List<SpectralIssue>>() {
class SpectralExternalAnnotator : ExternalAnnotator<Pair<PsiFile, Editor>, List<SpectralIssue>>() {
companion object {
val logger = getLogger()
}

override fun collectInformation(file: PsiFile, editor: Editor, hasErrors: Boolean): Pair<PsiFile,Editor>? {
override fun collectInformation(file: PsiFile, editor: Editor, hasErrors: Boolean): Pair<PsiFile, Editor>? {
if (file !is JsonFile && file !is YAMLFile) return null

try {
Expand Down Expand Up @@ -52,7 +52,7 @@ class SpectralExternalAnnotator : ExternalAnnotator<Pair<PsiFile,Editor>, List<S
return fileMatcher.matches(file.virtualFile.toNioPath())
}

override fun doAnnotate(info: Pair<PsiFile,Editor>): List<SpectralIssue> {
override fun doAnnotate(info: Pair<PsiFile, Editor>): List<SpectralIssue> {
val progressManager = ProgressManager.getInstance()
val computable = Computable { lintFile(info.second) }
val indicator = BackgroundableProcessIndicator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.text.ParseException
import java.time.Duration
import java.util.concurrent.ExecutionException

@Service
@Service(Service.Level.PROJECT)
class SpectralRunner(private val project: Project) {
companion object {
private val logger = getLogger()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.schwarzit.spectralIntellijPlugin.settings

import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil
Expand All @@ -9,6 +10,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
name = "com.schwarzit.spectralIntellijPlugin.settings.ProjectSettingsState",
storages = [Storage("spectral.xml")]
)
@Service(Service.Level.PROJECT)
class ProjectSettingsState : PersistentStateComponent<ProjectSettingsState> {

var ruleset: String = "https://raw.githubusercontent.com/SchwarzIT/api-linter-rules/main/spectral-api.yml"
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<id>com.schwarzit.spectral-intellij-plugin</id>
<name>Spectral</name>
<vendor>SchwarzIT</vendor>

<depends>com.intellij.modules.platform</depends>
<depends>org.jetbrains.plugins.yaml</depends>

Expand All @@ -21,6 +21,5 @@
instance="com.schwarzit.spectralIntellijPlugin.settings.ProjectSettingsConfigurable"
id="com.schwarzit.spectralIntellijPlugin.settings.ProjectSettingsConfigurable"
displayName="Spectral" nonDefaultProject="true"/>
<projectService serviceImplementation="com.schwarzit.spectralIntellijPlugin.settings.ProjectSettingsState"/>
</extensions>
</idea-plugin>

0 comments on commit 8397c17

Please sign in to comment.