PVS-Studio 8.00: анализаторы для JavaScript, TypeScript и Go, плагины для WebStorm и GoLand и многое другое

Вышел новый релиз PVS-Studio — 8.00. В нём: новые анализаторы для проектов на JavaScript, TypeScript и Go, новые IDE плагины для WebStorm и GoLand, расширение поддержки MISRA C++ 2023 и многое другое.

Новые анализаторы и плагины для IDE

В новой major версии PVS-Studio 8 стали доступны новые анализаторы для языков JavaScript, TypeScript и Go.

В первой редакции анализаторы содержат базовый набор диагностических правил, CLI для каждого анализатора, а также плагины для интегрированных сред разработки WebStorm и GoLand.

В плагине PVS-Studio для Visual Studio Code также произошли масштабные изменения. Помимо поддержки новых анализаторов, теперь в плагине есть возможность конфигурировать каждый анализатор через панель настроек.

Файлы конфигурации pvs-settings.toml

Для настройки новых анализаторов и плагинов, а также обновлённого расширения для Visual Studio Code теперь используется новый тип файлов конфигурации в формате TOML.

При его разработке мы постарались учесть все возможные сценарии, чтобы предоставить максимально удобный опыт использования.

Подробнее о новых файлах конфигурации можно прочитать в этом разделе документации.

MISRA C++ 2023

Мы продолжаем работать над улучшением поддержки стандарта MISRA C++ 2023.

В новой версии мы адаптировали 16 существующих диагностических правил группы MISRA под стандарт MISRA C++ 2023.

Подробнее о поддержке стандартов MISRA можно прочитать на этой странице.

Новые интеграции

За время, прошедшее с предыдущей версии, в списке интеграций PVS-Studio произошло пополнение.

В нашей документации появился раздел с описанием процесса интеграции анализатора в интеллектуальную платформу защищённой разработки SolidLab SDP. Теперь PVS-Studio возможно использовать в качестве SAST инструмента при автоматизации процессов SSDLC средствами платформы.

А в GitVerse Starter Workflow — коллекции шаблонов для CI/CD внутри платформы совместной разработки GitVerse — появились шаблоны для запуска анализа с помощью PVS-Studio. Благодаря этим шаблонам можно быстро интегрировать PVS-Studio в проект, минимально адаптировав команды под его особенности.

Поддержка компиляторов

В этом релизе мы также расширили список компиляторов C и C++, совместимых с анализатором PVS-Studio для этих языков.

На Linux в утилите pvs-studio-analyzer поддержана работа с компилятором x86_64-pc-linux-gnu-c++.

Также поддержана работа с компиляторами kcc ARMV7 и TI C2000-CGT на всех платформах с помощью мониторинга/трассировки компиляции.

Плагин для Qt Creator 20

Появилась поддержка плагина PVS-Studio для Qt Creator версий 20.x. Плагин позволяет запускать анализ, просматривать предупреждения и работать с кодом, не покидая привычную среду разработки.

Прекращена поддержка плагина для версий Qt Creator 14.x. Мы стараемся обеспечивать обратную совместимость по поддержке последних версий плагинов для всех версий Qt Creator за последние два года с момента каждого релиза.

Подробнее о работе с плагином можно прочитать в документации.

Система расширенного логирования для MSBuild проектов

Мы продолжаем внедрение новой системы логирования, благодаря которой мы можем проще диагностировать проблемы, возникающие при работе анализаторов PVS-Studio.

Ранее мы добавляли расширенное логирование в кроссплатформенный анализатор C и C++ проектов. Теперь пришёл черёд анализатора C++ и C# MSBuild-проектов.

Подробнее о новой системе логирования можно прочитать в документации.

Breaking Changes

Эти изменения ломают обратную совместимость с предыдущими версиями анализатора. В связи с этим вам может потребоваться изменить способ использования анализатора.

  • Для Unreal Engine проектов флаг //V_USE_OLD_PARSER в файле .pvsconfig теперь игнорируется. С развитием нового парсера C++ анализатора мы рекомендуем использовать его по умолчанию для всех проверяемых проектов. Теперь новый парсер будет включён по умолчанию в проектах, использующих более старые версии Unreal Engine, даже если в исходных файлах движка присутствует флаг //V_USE_OLD_PARSER.

  • В Java анализаторе добавлена сортировка содержимого файлов подавления. Это не меняет результат работы анализатора, но может привести к появлению больших различий при обновлении suppress-файлов, заложенных в системе контроля версий.

  • В ряде случаев для диагностических правил V2558 и V547 изменены сообщения. Возможно повторное попадание в отчёт ранее подавленных сообщений этих правил.

  • В связи с масштабными изменениями в расширении Visual Studio Code для поддержки новых анализаторов PVS-Studio мы поднимаем минимально поддерживаемую версию этой IDE для работы с расширением с 1.74 (ноябрь 2022) до 1.100 (апрель 2025).

Новые диагностические правила

Java

  • V6136. Values of bit flags are duplicated.

JavaScript и TypeScript

  • V7001. Operands of a binary operator are equivalent.

  • V7002. The body of a function is fully equivalent to the body of another function.

  • V7003. A condition is equivalent to a condition in an ‘else if’ statement, making it unreachable.

  • V7004. The ‘then’ statement is equivalent to the ‘else’ statement.

  • V7005. A variable is assigned to itself.

  • V7006. An exception is created but never used. The ‘throw’ keyword may be missing.

  • V7007. The ‘|’ and ‘&’ operators bypass short-circuit evaluation. The right-hand operand will be evaluated even when the left operand is false.

  • V7008. Two or more ‘case’ branches perform the same actions.

  • V7009. A parameter is not used in a function, constructor, or method.

  • V7010. The return value of the function is required to be utilized.

  • V7011. Comparison with ‘NaN’ is incorrect. Use ‘isNaN()’ or ‘Number.isNaN()’ method instead.

  • V7012. The conditional expression always returns the same value.

  • V7013. Suspicious assignment in the condition. A comparison may have been intended.

  • V7014. An identical expression to the left and to the right of a compound assignment.

  • V7015. Suspicious formatting of assignment and unary operators.

  • V7016. Suspicious access to a collection element by a constant index inside a loop.

  • V7017. A loop counter is not used for collection indexing in the inner loop.

  • V7018. The expression ‘A || (A && B)’ is redundant and always evaluates to ‘A’.

  • V7019. A variable is used as a counter for both inner and outer loops.

  • V7020. Suspicious code formatting. Curly brackets may be missing.

  • V7021. The postfix increment or decrement has no effect because the variable is overwritten.

  • V7022. It is possible that this ‘else’ branch should belong to the previous ‘if’ statement.

  • V7023. Suspicious use of a variable in similar code fragments. This may be a typo, and a different variable was intended.

  • V7024. Suspicious sub-expression in sequence of similar comparisons.

  • V7025. It is possible that an assigned variable should be checked in the following condition. Consider checking for a typo.

  • V7026. A stray semicolon after the condition of an if, for or while statement.

  • V7027. An object is passed as an argument to its own method.

  • V7028. A user-defined mathematical constant is used instead of a built-in constant. The resulting value may be inaccurate.

  • V7029. The line may have been commented out improperly, resulting in altered control flow.

  • V7030. Suspicious code formatting. The ‘else’ keyword may be missing.

  • V7031. A suspicious label was found inside a ‘switch’ statement. This may be a typo, and a different label was intended.

  • V7032. The loop counter is compared to its own initial value.

  • V7033. Suspicious similar comparisons. A typo may be present inside the expression.

  • V7034. The method in the child class does not override or implement the method of the ancestor class. A typo may be present in the name of the child class method.

  • V7035. Suspicious property implementation. Another field should probably be returned or assigned instead.

  • V7036. Suspicious precise comparison. Consider using a comparison with defined precision.

  • V7037. The nested loop counter is initialized with the outer loop counter.

  • V7038. The loop condition may be incorrect. The condition and update expression of the loop use different variables.

  • V7039. Unreachable code detected. Control flow never reaches this statement.

  • V7040. Infinite recursion detected.

  • V5801. OWASP. Code contains invisible characters that may alter its logic. Consider enabling the display of invisible characters in the code editor.

Go

  • V8001. Identical sub-expressions to the left and to the right of the ‘foo’ operator.

  • V8002. A variable is assigned to itself.

  • V8003. Consider inspecting the expression. Probably one of the operators should be used here: ‘-=’, ‘+=’ or ‘!=’.

  • V8004. The use of ‘if A {…} else if A {…}’ pattern was detected. A potential logical error is present.

  • V8005. The ‘then’ statement is equivalent to the ‘else’ statement.

  • V8006. Unconditional ‘break/continue/return/goto’ within a loop.

  • V8007. Calling the ‘recover’ function inside the anonymous function that is not deferred will not recover execution from panic.

  • V8008. Suspicious access to a collection element by a constant index inside a loop.

  • V8009. Two or more ‘case’ branches perform the same actions.

  • V8010. Two or more ‘case’ branches have equivalent expressions.

  • V8011. An identical expression to the left and to the right of a compound assignment.

  • V8012. A function always returns the same value. Consider inspecting the program logic.

  • V8013. Incorrect format. A different number of format items is expected.

  • V8014. Two ‘if’ statements have identical conditions. The first ‘if’ statement contains function return, making the second ‘if’ redundant, or the code contains a logical error.

  • V8015. Suspicious use of the bitwise XOR operator ‘^’. The exponentiation operation may have been intended here.

  • V8016. The loop may be executed incorrectly or its condition will never be met. Inspect initial and final values in the ‘for’ loop.

  • V8017. The conditions of two adjacent ‘if’ statements are equivalent.

  • V8018. Comparison with ‘math.NaN()’ is meaningless. Use the ‘math.IsNaN()’ function instead.

  • V8019. Two or more equivalent expressions are specified inside the case expression list.

  • V8020. Recurring check. This condition was already verified on a previous line.

  • V8021. Using a unary operator several times is meaningless or reverses the result.

  • V8022. A parameter is not used in a function or method.

  • V8023. It is possible that a wrong variable of the ‘error’ type is checked for ‘nil’.

  • V8024. Redundant type assertion. The type of a variable already embeds the type that is checked using type assertion.

  • V8025. The case in a type switch is unreachable. A previous case already covers this type.

  • V8026. The counter is not used inside the body of the nested loop.

  • V8027. Suspicious sub-expression in sequence of similar comparisons.

  • V8028. The outer loop counter is modified in

    Источник: habr.com

    0 0 голоса
    Рейтинг новости
    1
    0
Подписаться
Уведомить о
0 комментариев