혼란스러운 마이너스
이 경고 카테고리의 철자는 [confusing-minuses]
입니다.
혼란스러운 마이너스
무슨 일인가요?
자바스크립트 코드는 '-'로 작성된 연산자 조합을 혼동하는 방식으로 사용합니다. 인접한 '-' 연산자를 구분하기 어려울 수 있습니다. 이는 비정상적인 간격으로 인해 더 심해질 수 있습니다.
왜 나쁜가요?
코드를 읽기 어렵게 만들고 혼동을 일으킬 수 있습니다.
예시
import QtQuick Item { function f(a: int, b: int) { let x = a-- - b let y = a - -b let z = a - --b return x + y + z } }
이 경고를 해결하려면 비슷한 '-' 연산자가 나란히 포함되지 않도록 코드를 다시 작성하세요. 가능하면 표현식을 단순화하세요. 중복되는 단항 연산자와 띄어쓰기를 제거하고 괄호를 사용하여 하위 표현식을 구분합니다.
이러한 연산자는 강제를 수행할 수 있다는 점에 유의하세요. a - -b
같은 표현식은 b의 유형에 따라 a + b
과 같지 않을 수 있습니다.
import QtQuick Item { function f(a: int, b: int) { let x = (a--) - b let y = a + b let z = a - b + 1 return x + y + z } }
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.