Bump Novusvetus/action-phpinsights from 1.1.15 to 1.1.16 #58
Annotations
10 errors and 1 warning
phpinsights:
src/GitIgnoreFile.php#L78
* [Forbidden setter] Setters are not allowed. Use constructor injection and behavior naming instead.
* [Parameter type hint] Method \Novusvetus\AutoGitIgnore\GitIgnoreFile::setFile() does not have native type hint for its parameter $filePath but it should be possible to add it based on @param annotation "string".
|
phpinsights:
src/GitIgnoreFile.php#L189
* [Forbidden setter] Setters are not allowed. Use constructor injection and behavior naming instead.
* [Parameter type hint] Method \Novusvetus\AutoGitIgnore\GitIgnoreFile::setLines() does not have native type hint for its parameter $lines but it should be possible to add it based on @param annotation "array".
|
phpinsights:
src/GitIgnoreFile.php#L141
* [Disallow equal operators] Operator == is disallowed, use === instead.
|
phpinsights:
src/GitIgnoreFile.php#L157
* [Disallow equal operators] Operator == is disallowed, use === instead.
|
phpinsights:
src/GitIgnoreFile.php#L231
* [Disallow equal operators] Operator == is disallowed, use === instead.
|
phpinsights:
src/GitIgnoreFile.php#L1
* [Declare strict types] Expected 1 line before declare statement, found 0.
* [No useless else] @@ -146,3 +146,3 @@
);
- } else {
+ }
if ($found) {
@@ -152,3 +152,3 @@
);
- } else {
+ }
$open = true;
@@ -154,4 +154,4 @@
$open = true;
- }
- }
+
+
} elseif ($line == $this->endMarker) {
@@ -162,3 +162,3 @@
);
- } else {
+ }
$found = true;
@@ -166,3 +166,3 @@
$this->afterLine = count($this->fileContent);
- }
+
} else {
* [Having `classes` with more than 5 cyclomatic complexity is prohibited - Consider refactoring] 20 cyclomatic complexity
* [Normal classes are forbidden. Classes must be final or abstract]
* [Phpdoc trim] @@ -93,3 +93,2 @@
* @throws AutoGitIgnorePermissionException
- *
*/
@@ -131,3 +130,2 @@
* @throws AutoGitIgnoreParseException
- *
*/
@@ -206,3 +204,2 @@
* @throws AutoGitIgnoreSaveException
- *
*/
* [Ordered class elements] @@ -89,2 +89,80 @@
/**
+ * Gets the file path
+ *
+ * @return string
+ */
+ public function getFile(): string
+ {
+ return $this->filePath;
+ }
+
+ /**
+ * Set the paths to write in .gitignore file
+ *
+ * @param array $lines
+ *
+ * @return self
+ */
+ public function setLines($lines): GitIgnoreFile
+ {
+ if (!is_array($lines)) {
+ $this->lines = array(
+ $lines
+ );
+ } else {
+ $this->lines = $lines;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Save to the .gitinore file
+ *
+ * @return self
+ * @throws AutoGitIgnoreSaveException
+ *
+ */
+ public function save(): GitIgnoreFile
+ {
+ if ($this->afterLine === null) {
+ throw ClassHelper::create(
+ AutoGitIgnoreSaveException::class,
+ 'No file loaded.'
+ );
+ }
+
+ $output = array();
+ if ($this->afterLine === 0) {
+ $output[] = $this->startMarker;
+ foreach ($this->lines as $l) {
+ $output[] = $l;
+ }
+ $output[] = $this->endMarker;
+ }
+ $i = 0;
+ foreach ($this->fileContent as $line) {
+ $i++;
+
+ $output[] = $line;
+ if ($i == $this->afterLine) {
+ $output[] = $this->startMarker;
+ foreach ($this->lines as $l) {
+ $output[] = $l;
+ }
+ $output[] = $this->endMarker;
+ }
+ }
+
+ if (!file_put_contents($this->getFile(), implode(PHP_EOL, $output))) {
+ throw ClassHelper::create(
+ AutoGitIgnoreSaveException::class,
+ 'Saving to ' . $this->getFile() . ' failed.'
+ );
+ }
+
+ return $this;
+ }
+
+ /**
* Permission check
@@ -117,12 +195,2 @@
/**
- * Gets the file path
- *
- * @return string
- */
- public function getFile(): string
- {
- return $this->filePath;
- }
-
- /**
* Loads the .gitignore file and parses it.
@@ -176,70 +244,2 @@
$this->afterLine = count($this->fileContent);
- }
-
- return $this;
- }
-
- /**
- * Set the paths to write in .gitignore file
- *
- * @param array $lines
- *
- * @return self
- */
- public function setLines($lines): GitIgnoreFile
- {
- if (!is_array($lines)) {
- $this->lines = array(
- $lines
- );
- } else {
- $this->lines = $lines;
- }
-
- return $this;
- }
-
- /**
- * Save to the .gitinore file
- *
- * @return self
-
|
phpinsights:
src/GitIgnoreFile.php#L66
* [Parameter type hint] Method \Novusvetus\AutoGitIgnore\GitIgnoreFile::__construct() does not have native type hint for its parameter $filePath but it should be possible to add it based on @param annotation "string".
|
phpinsights:
src/GitIgnoreFile.php#L185
* [Parameter type hint] @param annotation of method \Novusvetus\AutoGitIgnore\GitIgnoreFile::setLines() does not specify type hint for items of its traversable parameter $lines.
|
phpinsights:
src/GitIgnoreFile.php#L29
* [Property type hint] Property \Novusvetus\AutoGitIgnore\GitIgnoreFile::$startMarker does not have native type hint for its value but it should be possible to add it based on @var annotation "string".
|
phpinsights:
src/GitIgnoreFile.php#L35
* [Property type hint] Property \Novusvetus\AutoGitIgnore\GitIgnoreFile::$endMarker does not have native type hint for its value but it should be possible to add it based on @var annotation "string".
|
phpinsights
The following actions uses node12 which is deprecated and will be forced to run on node16: Novusvetus/[email protected]. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
|