C4tWithShell / community-rust

SonarQube plugin to analyze Rust files
GNU Lesser General Public License v3.0
124 stars 10 forks source link

Error with parsing rs in Sonar #69

Closed C4tWithShell closed 1 year ago

C4tWithShell commented 1 year ago

Hi! I have a problem with rust sensor. It's unable to parse few of my files ( I marked places with ^):

ERROR: Parse error at line 788 column 47:

783: #[derive(Encode, Decode, Eq, PartialEq, Clone, PartialOrd, Ord, Debug, scale_info::TypeInfo)]
784: #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
785: #[repr(u8)]
786: pub enum TechPurpose<AssetId> {
787:     FeeCollector = 0,
788:     FeeCollectorForPair(TradingPair<AssetId>) = 1,
                                                   ^
789:     XykLiquidityKeeper(TradingPair<AssetId>) = 2,
....

ERROR: Parse error at line 519 column 13:

511:     /// Update rates in the storage with the new ones.
512:     ///
513:     /// `f` - mutation function which defines the way values should be updated.
514:     fn update_rates(
515:         rates: BoundedVec<(T::Symbol, u64), T::MaxRelaySymbols>,
516:         resolve_time: u64,
517:         request_id: u64,
518:         f: impl Fn(
519:             &mut Option<BandRate<BlockNumberFor<T>>>,
                 ^
elegoff commented 1 year ago

Thanks very much for your report which allowed a couple of parsing issues to be fixed

The first one (enum TechPurpose) was caused by wrong implementation of an EnumItem and that should now be fixed

The second was because we were wrongly assuming an impl Fn should be on one single line...

This was tested from the snippet you shared. Hopefully the fix also works on your full files...